我有一個奇怪的錯誤。我正在使用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