Ios 集合视图单元格加载时间
此my collectionView cellForItemAtIndexPath方法:Ios 集合视图单元格加载时间,ios,objective-c,uiview,uicollectionview,chess,Ios,Objective C,Uiview,Uicollectionview,Chess,此my collectionView cellForItemAtIndexPath方法: dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ ChessBoard *boardView = [[ChessBoard alloc] initWithFrame:CGRectMake(0, cell.frame.size.height - cell.frame
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
ChessBoard *boardView = [[ChessBoard alloc] initWithFrame:CGRectMake(0, cell.frame.size.height - cell.frame.size.width, cell.frame.size.width, cell.frame.size.width)];
boardView.fenString = self.fenArray[indexPath.item];
[boardView.highlightBoxes addObject:self.lastMoveFromSqiArray[indexPath.item]];
[boardView.highlightBoxes addObject:self.lastMoveToSqiArray[indexPath.item]];
NSLog(@"from %@, to %@", self.lastMoveFromSqiArray[indexPath.item], self.lastMoveToSqiArray[indexPath.item]);
boardView.showCoordinates = NO;
[boardView baseInit];
//main thread
dispatch_async(dispatch_get_main_queue(), ^{
[cell addSubview:boardView];
});
});
cell.layer.shouldRasterize = YES;
cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
return cell;
ChessBoard是一个UIView子类,它返回一个UIView,其中绘制了棋盘
运行此操作时,加载视图控制器时单元格中没有任何内容,加载单元格需要花费太多时间。
有什么办法可以改进吗?添加加载屏幕,直到所有单元格加载完毕。。或者只是尝试呈现控制器,并在其完成部分使加载程序离开。。。就好像屏幕上显示的单元格太多,它们肯定需要时间加载,但加载需要10-15秒以上,这是非常多的。请看,屏幕上显示的单元格数量肯定会加载。你不能阻止。