我是 iOS 开发的新手,在我的应用程序中,我需要在heightForRowAtIndexPath
方法中计算动态表格单元格的高度。
问题是我不想在“回调”块完成之前返回值..objective-c 中有没有办法做到这一点?
这是我的方法实现:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
SDImageCache *imageCache = [[SDImageCache alloc] init];
[imageCache queryDiskCacheForKey:model.thumbnail done:^(UIImage *image, SDImageCacheType cacheType)
{
// do calculations with height etc.
// got an error "incompatible block pointer types sending"
return value;
}];
}