Ipad 在tabbar控制器中与uisplitviewController一起使用时,tableView上的重新加载数据会崩溃
我正在使用一个tabbar应用程序。在其中一个选项卡中,我将tableView控制器嵌入为SplitView。当此选项卡变为活动状态时,我会进行URL调用以从服务器获取一些数据。我无法在tableView中填充数据。我尝试了“[self.tableView reloadData]”,但应用程序崩溃。我的ViewController类是UITableViewController的子类Ipad 在tabbar控制器中与uisplitviewController一起使用时,tableView上的重新加载数据会崩溃,ipad,uitabbarcontroller,uitableview,uisplitviewcontroller,ios5.1,Ipad,Uitabbarcontroller,Uitableview,Uisplitviewcontroller,Ios5.1,我正在使用一个tabbar应用程序。在其中一个选项卡中,我将tableView控制器嵌入为SplitView。当此选项卡变为活动状态时,我会进行URL调用以从服务器获取一些数据。我无法在tableView中填充数据。我尝试了“[self.tableView reloadData]”,但应用程序崩溃。我的ViewController类是UITableViewController的子类 - (void)didReceiveUserListFromServer { NSData *jsonData =
- (void)didReceiveUserListFromServer
{
NSData *jsonData = responseData;
NSError *error=nil;
NSMutableDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONWritingPrettyPrinted error:&error];
userDetailsArray = [responseDict objectForKey:@"userDetails"];
NSLog(@"count===%d",[userDetailsArray count]); //This returns a non-zero number
[self.tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [userDetailsArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ReturningPatientSearchResultCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSMutableDictionary *singleUserDetail = [userDetailsArray objectAtIndex:indexPath.row];
cell.textLabel.text=[singleUserDetail objectForKey:@"Name"]; //EXC_BAD_ACCESS here
return cell;
}
我会尝试将
userDetailsArray
设置为类中的strong属性,并使用self.userDetailsArray
设置其值和引用
(奇怪的是,数组对计数有效,对以后的访问无效,但释放的内存似乎是最符合逻辑的解释。)
您还可以尝试为您的构建方案打开僵尸,看看这是否提供了更好的信息。如果在崩溃前记录singleUserDetail
或userDetailsArray
的值,您会看到什么?@PhillipMills It崩溃时没有记录任何值。