我想将uiimage设置为函数范围之外的变量.i尝试了下面的代码,但它不起作用。以下代码用于自定义可用视图单元类。所以我不能分配和初始化它。因为这将导致初始化它显示/滚动每次细胞如何将ui映像复制到另一个变量?
uiimage *img;
[manager downloadWithURL:[NSURL URLWithString:friendData.picUrl] options:SDWebImageRefreshCached progress:^(NSInteger receivedSize, NSInteger expectedSize) {
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
img =image; ////this is not working !!
}];
dispatch_async(dispatch_get_main_queue(), ^{
[cell.profileImage setImage:img]; //and off course this wont work too
});
ü可以张贴一些代码function.try的地方是'的UIImage *图像1 '被宣布? – sreekanthk 2014-09-19 07:11:40
也许你需要在分配UIImage值之前启动它?尝试UIImage * img = [[UIImage alloc] init]; – felixwcf 2014-09-19 07:24:19