当与tabbar控制器中的uisplitviewController一起使用时,tableView上的reloadData崩溃

时间:2012-09-24 13:42:41

标签: ipad uitabbarcontroller uitableview uisplitviewcontroller ios5.1

我正在使用tabbar应用程序。在其中一个选项卡中,我有一个嵌入了SplitView的tableView控制器。当此选项卡变为活动状态时,我进行URL调用以从服务器获取一些数据。我无法填充tableView中的数据。我试过'[self.tableView reloadData]'但是应用程序崩溃了。我的ViewController类被子类化为UITableViewController。

- (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;
}

1 个答案:

答案 0 :(得分:0)

我尝试在您的班级中使用userDetailsArray 属性,并使用self.userDetailsArray设置其值和对它的引用。

(奇怪的是,该数组对count有效,而不是以后的访问,但释放的内存似乎是最合乎逻辑的解释。)

你也可以尝试为你的构建方案打开僵尸,看看是否能提供更好的信息。