У меня странная ошибка. Я использую UITableView
, который необходимо перезагрузить при выборе строки. Это отлично работает в симуляторе iPhone. Во время работы в iPad вызывается didSelectRowAtIndexPath
, но пользовательский интерфейс не обновляется. Я пробовал называть метод reloadData
в основной теме. Это все равно.TableView reloadData не обновляет интерфейс в iPad, но работает в iPhone
Я попытался использовать различные решения в stackoverflow. Ничто, казалось, не исправило мою проблему.
UPDATE
Когда я выбрать ячейку, будет добавлена новая ячейка. Поэтому мне нужно перезагрузить мое табличное представление, чтобы отобразить динамическое изменение. Добавлено мой код ниже
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath
{
NSUInteger count=indexPath.row+1;
NSMutableArray *insertIndexPaths = [NSMutableArray array];
[insertIndexPaths addObject:[NSIndexPath indexPathForRow:count inSection:indexPath.section]];
switch (indexPath.row) {
case 0:
{
if ([ItemsInSection[indexPath.section] count]==1){
[ItemsInSection[indexPath.section] addObject:obj2];
[TabView beginUpdates];
[TabView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationLeft];
[TabView endUpdates];
}
else {
[ItemsInSection[indexPath.section] removeAllObjects];
[ItemsInSection[indexPath.section] addObject:obj1];
[self.TabView reloadData];
}
}
break;
case 1:
{if ([ItemsInSection[indexPath.section] count]==2){
[ItemsInSection[indexPath.section] addObject:obj3];
[self.TabView beginUpdates];
[TabView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationLeft];
[self.TabView endUpdates];
}
else
{
[ItemsInSection[indexPath.section] removeAllObjects];
[ItemsInSection[indexPath.section] addObject:obj1];
[ItemsInSection[indexPath.section] addObject:obj2];
[self.TabView reloadData];
}
}
break;
case 2: {
if ([ItemsInSection[indexPath.section] count]==3) {
[ItemsInSection[indexPath.section] addObject:obj4];
[self.TabView beginUpdates];
[TabView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationLeft];
[self.TabView endUpdates];
}
else
{
[ItemsInSection[indexPath.section] removeObject:obj4];
[self.TabView beginUpdates];
[TabView deleteRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationLeft];
[self.TabView endUpdates];
}
}
break;
default:
break;
}
}
Вы должны выслать свой код. Мне кажется, проблема в другом месте. Кроме того, почему вы хотите перезагрузить весь вид таблицы при выборе ячейки? Просьба описать фактическую цель, которую вы пытаетесь достичь, вместо того, чтобы искать решение для неработоспособной попытки. – ozgur