Я переписал твой код.
if (tableView == self.numberTableView) {
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.text = [NSString stringWithFormat:@"%i", indexPath.row];
if (inumberfont == indexPath.row) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
Приведенный выше код делает то же самое, что и ваш код, но ваш код не работает. В следующем коде я исправил обнаруженные ошибки. Я также добавил недостающий код. Если вы имели это раньше, но не включали это, это нормально; Я просто хотел убедиться, что это не пропало.
if (tableView == self.numberTableView) {
static NSString *CellIdentifier = @"NumberCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [NSString stringWithFormat:@"%i", indexPath.row];
if (inumberfont == indexPath.row) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}
Я не уверен, что вы подразумеваете под "аксессуаром галочки не работает", но попробуйте улучшить ваш код с моими предложениями, и если он все еще не работает, оставьте комментарий, и я посмотрю, что я могу сделать, чтобы помочь вам в дальнейшем.
РЕДАКТИРОВАТЬ: Выяснил, в чем проблема. Попробуйте следующее:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
inumberfont = indexPath.row;
[tableView reloadData];
}