我有一个奇怪的错误。我正在使用UITableView
,当一行被选中时,必须重新加载它。这在iPhone模拟器中正常工作。在iPad上运行时,didSelectRowAtIndexPath
正在调用,但UI没有更新。 我试着在主线程上调用方法reloadData
。它仍然是一样的。TableView reloadData不会更新iPad中的UI,但可用于iPhone
我已经尝试了各种解决方案在stackoverflow。似乎没有什么能解决我的问题。
UPDATE
当我选择的小区,新的小区将被添加。所以我需要重新加载我的tableview来显示动态变化。 发布以下
- (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