У меня есть два вопросаUITableView ячейки пустой, но правильный текст в консоли
1) если я не закомментировать если (== клеток ноль), то текстовые метки не показывают в одном из моих tableviews на моем телефоне.
2) у меня другая проблема, но если у меня это прокомментировано, текст не изменится. Однако, если я
NSLog(@"did select and the text is %@",[tableView cellForRowAtIndexPath:indexPath].textLabel.text);
я получаю выход «сделал выбор и текст" Сайт номер 1», который является то, что я хочу, однако текст, который я вижу на экране телефона не то, что я вижу в консоли может ли кто-нибудь помочь? вот мой код:
мой идентификатор ячейки в атрибуты инспектора Tableview является «selcell»
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
int row=indexPath.row;
NSLog(@"number in sites is %d cell for row %@",[sites count],[sites objectAtIndex:row]);
static NSString *CellIdentifier = @"selcell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// if(cell==nil)
// {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.text=[NSString stringWithFormat:@"site number %@",[sites objectAtIndex:row]];
// }
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"did select and the text is %@",[tableView cellForRowAtIndexPath:indexPath].textLabel.text);
[self.delegate didSelectSite:[sites objectAtIndex:indexPath.row]];
}
спасибо так много, что была проблема –