这是代码的一部分,用于在相册中显示系统 它在ios6中运行良好。不是ios7。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"GridCell";
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
CGRect frame = [AGImagePickerController itemRect];
CGFloat leftMargin = frame.origin.x;
for (AGIPCGridItem *gridItem in [self itemsForRowAtIndexPath:indexPath])
{
[gridItem setFrame:frame];
UITapGestureRecognizer *selectionGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:gridItem action:@selector(tap)];
selectionGestureRecognizer.numberOfTapsRequired = 1;
[gridItem addGestureRecognizer:selectionGestureRecognizer];
[selectionGestureRecognizer release];
[cell addSubview:gridItem];
frame.origin.x = frame.origin.x + frame.size.width + leftMargin;
}
}
return cell;
}
AGImagePickerController的链接 https://github.com/arturgrigor/AGImagePickerController
请帮帮我!非常感谢!
答案 0 :(得分:3)
我通过文件AGIPCAssetsController.m
中的代码得到了一个解决方案- (void)loadAssets{
[self.assets removeAllObjects];
__block AGIPCAssetsController *blockSelf = self;
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
#endif
@autoreleasepool {
[blockSelf.assetsGroup enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (result == nil)
{
return;
}
AGIPCGridItem *gridItem = [[AGIPCGridItem alloc] initWithAsset:result andDelegate:blockSelf];
if ( blockSelf.imagePickerController.selection != nil &&
[blockSelf.imagePickerController.selection containsObject:result])
{
gridItem.selected = YES;
}
[blockSelf.assets addObject:gridItem];
[gridItem release];
}];
}
dispatch_async(dispatch_get_main_queue(), ^{
[blockSelf reloadData];
});
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
});
#endif
}
我不确定这种治疗方法是否有问题?但是,我在ios6和ios7中都测试了这段代码并计算了ipad2中dispatch_async方法的成本时间,大约500张照片使用了0.4秒..所以我认为摆脱这个dispatch_aysnc没有太大的影响!
希望有用,祝福!