我有我的代码,我通过SDWebImage框架从URL下载图像
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:self.bigArtworkURL
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
} completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
if (image !=nil) {
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
[songInfo setObject:self.listStationCurrent forKey:MPMediaItemPropertyTitle];
[songInfo setObject:[NSString stringWithFormat:@"%@-%@",self.title,self.artist] forKey:MPMediaItemPropertyArtist];
MPMediaItemArtwork *imageArt = [[MPMediaItemArtwork alloc] initWithImage:image];
[songInfo setObject:imageArt forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
}else{
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
[songInfo setObject:self.listStationCurrent forKey:MPMediaItemPropertyTitle];
[songInfo setObject:[NSString stringWithFormat:@"%@-%@",self.title,self.artist] forKey:MPMediaItemPropertyAlbumTitle];
MPMediaItemArtwork *imageArt = [[MPMediaItemArtwork alloc] initWithImage:[UIImage imageNamed:PLACEHOLDER_EMPTY]];
[songInfo setObject:imageArt forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
}}];
}
} failureHandler:^(NSError *error) {
}];
当我更新新框架SDWebImage时,我开始收到以下错误:
Incompatible block pointer types sending 'void (^)(NSInteger, NSInteger)' to parameter of type 'SDWebImageDownloaderProgressBlock _Nullable' (aka 'void (^)(NSInteger, NSInteger, NSURL * _Nullable __strong)')
在我找到解决方案但我不知道我必须把这条线放在哪里..
typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished);
请帮助我必须把这条线放在哪里,而不是更多。
答案 0 :(得分:0)
这是SDWebImageView的新代码。我使用了以下代码,它为我工作。
[[SDWebImageManager sharedManager]downloadImageWithURL:[NSURL URLWithString:ImageUrl] options:SDWebImageRefreshCached progress:^(NSInteger receivedSize, NSInteger expectedSize)
{
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL)
{
if (finished==true)
{
if (error==nil)
{
//Here is the downloaded image
UIImage *DownloadedImage=image;
}
else
{
NSLog(@"%@",error.localizedDescription);
}
}
}];