tra*_*uan 7 objective-c ios afnetworking
我的目的是尝试通过成功的块获取下载图像的大小,如下所示:
[imageView setImageWithURLRequest:[NSURL URLWithString:((ObjectA*)obj[indexPath.row]).imageUrl]
placeholderImage:nil
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
CGFloat imageHeight = image.size.height;
CGFloat imageWidth = image.size.width;
NSLog(@"width of image is %f",imageWidth);
NSLog(@"height of image is %f",imageHeight);
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
;
} ];
Run Code Online (Sandbox Code Playgroud)
但是,我遇到了崩溃,显示如下错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL cachePolicy]: unrecognized selector sent to instance 0x1edb9e70'
Run Code Online (Sandbox Code Playgroud)
有谁知道这个错误的原因.如果您有任何想法,请帮忙
Mid*_* MP 12
问题是这个代码:
[imageView setImageWithURLRequest:[NSURL URLWithString:((ObjectA*)obj[indexPath.row]).imageUrl]
Run Code Online (Sandbox Code Playgroud)
参数setImageWithURLRequest:是NSURLRequest,你正在通过NSURL.这就是崩溃的原因.
将其更改为:
[imageViewsetImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:((ObjectA*)obj[indexPath.row]).imageUrl]]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2122 次 |
| 最近记录: |