カスタムセルでテーブルビューを作成しようとしました。いくつかのチュートリアルを見ましたが、新しいプロジェクトを開く代わりに、ステップバイステップに従ってください。今のやつでやってみた。そうすれば、問題を解決し、さらに学ぶことができます。
これまでに行った手順は次のとおりです。単純なテーブルビュー:
(WorkoutList.xib)
WorkoutList.h (workoutTableView は上の図で見たものです)
WorkoutList.m:
- (void)viewDidLoad
{
[super viewDidLoad];
self.workoutTableView.dataSource = self;
self.workoutTableView.delegate = self;
TitleArray = [[NSArray alloc] initWithObjects:@"First", @"Second", @"Third", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return TitleArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
WorkoutCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
{
cell = [[WorkoutCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.workoutTitle.text = [TitleArray objectAtIndex:indexPath.row];
cell.workoutImage.image = [UIImage imageNamed:@"list-item-icon3"];
return cell;
}
WorkoutCell.xib:
カスタム クラス: WorkoutCell 識別子: Cell
WorkoutCell.h:
私が見るのは空のTableViewだけです..
長い質問であることは承知していますが、それを理解し、自分の間違いがどこにあるかを確認することは、私にとって本当に重要です。どうもありがとう !