MELCore Data
のリストを使用しUITableViewControllers
て表示するアプリを作成しています。
私はすべてをやりましたが、UITableViewCell
編集可能かどうかをチェックすることはできません。これは、私の問題を想像するのに役立つはずのアプリのスクリーンショットです。
セクションがあるかどうかを確認しchapter
ています。これが true の場合はすべてが黒で表示され、そうでない場合はdetailTextLabel
色が赤に変更されます。しかし、ご覧のとおり、一部のセルにはセクションがあっても色が付けられています。それはどのように可能ですか?
これが私のtableView:cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Initializing Cell and filling it with info
Chapter *chapter = [self.MELs objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [NSString stringWithFormat:@"Number: %@ \t Sections: %lu", chapter.number, (unsigned long)[chapter.sections count]];
cell.textLabel.text = [chapter.title capitalizedString];
if ([chapter.sections count] == 0) {
[cell.detailTextLabel setTextColor:[UIColor redColor]];
}
return cell;
}