У меня другая проблема.
Я создаю свои TableViewCells вроде:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
UILabel *label = nil;
NSString *cellIdentifier = [NSString stringWithFormat:@"Cell_%i", indexPath.row];
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellIdentifier] autorelease];
//cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellIdentifier];
label = [[UILabel alloc] initWithFrame:CGRectZero];
[label setLineBreakMode:UILineBreakModeWordWrap];
[label setMinimumFontSize:FONT_SIZE];
[label setNumberOfLines:0];
[label setFont:[UIFont systemFontOfSize:FONT_SIZE]];
[label setTag:1];
[[cell contentView] addSubview:label];
}
return cell;
}
, как вы видите, у меня есть ячейки с идентификаторами, такими как "Cell_0, Cell_1 и т. Д."
и в функции, которая не является методом TableView, я хочу использовать эти ячейки, вызывая их идентификаторы.я делаю это следующим образом:
UITableViewCell *cell = [myTableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"Cell_%i", myCellID]];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:[NSString stringWithFormat:@"Cell_%i", myCellID]];
}
UILabel *label = (UILabel*)[cell viewWithTag:1];
Не могу ли я использовать как это?
Я пытаюсь изменить цвет метки в ячейке, к которой я пытаюсь получить доступ, но я не могу.ячейка не ноль, но метка всегда ноль.что мне делать?
как я могу понять, если это ячейка, которую я хочу, или пустая ячейка?