重新加载时iOS 9 UITableview冻结(xcode 7)
我有要在tableview中加载的数组对象。我的tableview代理是重新加载时iOS 9 UITableview冻结(xcode 7),ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有要在tableview中加载的数组对象。我的tableview代理是 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 90; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { re
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 90;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return currentArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"LessonCellID";
LessionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
//210 231 246
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if (indexPath.row%2==0) {
[cell setBackgroundColor:[UIColor colorWithRed:238/255.0 green:238/255.0 blue:238/255.0 alpha:1.0]];
}else{
[cell setBackgroundColor:[UIColor colorWithRed:210/255.0 green:231/255.0 blue:246/255.0 alpha:1]];
}
cell.labelDate.text = [[currentArray objectAtIndex:indexPath.row] objectForKey:@"DateCaption"];
cell.labelTitle.text = [[currentArray objectAtIndex:indexPath.row] objectForKey:@"Description"];
return cell;
}
从服务器获取值后,我的代码
currentArray = [[NSMutableArray alloc] initWithArray:result];
[self.tableViewSubjects reloadData];
当我运行此代码时,我的应用程序冻结,我无法执行任何操作。它会阻塞整个UI。如果我删除了“reloadData”代码,那么就不会有更多的冻结,但我想将数据加载到tableview中。所以我不得不称之为“重新加载数据”
请任何人帮我找到原因
注:
仅当我在UITableviewCell类上未使用自定义单元格(LessionTableViewCell或任何自定义单元格)时,才会出现此问题。我在故事板上有我的自定义单元格(在我的视图控制器nib中),分别创建了“.h”和“.m”文件,并在文件检查器上设置了单元格类
您正在调用哪个线程重新加载?您配置了应用程序吗?@Wain。我通过dispatch_async(dispatch_get_Main_queue(),^{})在主线程上调用它@engmahsa我不擅长分析(如果你暂停它,它会做什么?你在调用哪个线程重新加载?你对应用程序进行了评测吗?@Wain.我在主线程上通过dispatch_async(dispatch_get_Main_queue(),^{});@engmahsa调用它,我不擅长评测…:(如果你暂停它,它会做什么?