我想將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