カスタムテーブルビューセルを介して設計されているUITableビューがあります。セルごとにテキストを変えたいのでlabel
、CustomCellにを追加して接続しましたIBOutlet
が、コードのロジック部分に頭を巻くのに非常に苦労しています。私はこれまでにこれを持っています:
//これは私のテーブルビューコントローラークラスにあります。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *object = [[NSBundle mainBundle]loadNibNamed:@"TableOfContentsCell" owner:self options:nil];
for (id currentObject in object) {
if ([currentObject isKindOfClass:[UITableViewCell class]]) {
cell = (TableOfContentsCell *)currentObject;
break;
}
}
}
//cell.textLabel.textColor = [UIColor whiteColor];
// Configure the cell...
return cell;
}
//This is in my Custom Table View Cell Class.
-(void)setTableText{
cellLabel.text = [table.tableCellText objectAtIndex:0];
}
必要なテキストが配列内にあるときに、テキストを設定する方法がわかりません。