我的ViewController中有2个单独的UICollectionView,我试图使用以下代码从URL加载图像。为了缓存图像并以异步方式加载它,我开始通过可可豆荚使用SDWebImage 5.0。但是我的应用程序崩溃,并显示以下消息。我尝试了SDWebImage的早期版本,但仍然遇到此问题。我什至在其他链接标志中添加了-ObjC标志:
-[UIImageView sd_setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x143d05420
2019-12-28 12:12:48.436501+0530 BlondWaves[6037:907402] TIC Read Status [1:0x0]: 1:57
2019-12-28 12:12:48.438329+0530 BlondWaves[6037:907224] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView sd_setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x143d05420'
*** First throw call stack:
(0x1fc02f180 0x1fb2079f8 0x1fbf4b9bc 0x22868e220 0x1fc0349c8 0x1fc03665c 0x100f1b070 0x227f54e44 0x227f58efc 0x227f5d8bc 0x228afa170 0x20056cc60 0x200571c08 0x2004d43e4 0x200502620 0x22865c7e0 0x228745408 0x22873e330 0x1fbfc0f1c 0x1fbfc0e9c 0x1fbfc07d4 0x1fbfbb6c0 0x1fbfbafb4 0x1fe1bc79c 0x228662c38 0x100f1d4f0 0x1fba7e8e0)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
这是我的UICollectionView代码:
//loading featured collection data
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if(collectionView == self.collectionView){
return _resultArray.count;
}else{
return _resultArray.count;
}
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if(collectionView == self.collectionView){
NSString *urlString = [[_resultArray objectAtIndex:indexPath.row] valueForKey:@"url"];
NSLog(@"%@",urlString);
featuredCell *cell =[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
[cell.photo sd_setImageWithURL:[NSURL URLWithString:urlString]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
return cell;
}else{
NSString *urlString = [[_userArray objectAtIndex:indexPath.row] valueForKey:@"url"];
NSLog(@"%@",urlString);
userCell *cell =[collectionView dequeueReusableCellWithReuseIdentifier:@"user" forIndexPath:indexPath];
[cell.userphoto sd_setImageWithURL:[NSURL URLWithString:urlString]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
return cell;
}
}