我使用image
这样设置url
:
[self.imageView setMyImageWithURL:[NSURL URLWithString:[trip.destination getHeaderImageUrl] ]];
- (void)setMYImageWithURL:(NSURL *)url {
[self setBackground];
if(url.absoluteString.length >0){
__block UIImageView *safeSelf = self;
UIImage *placeholderImage = [UIImage imageNamed:[NSString stringWithFormat:@"placeholderpic_%@.png", NSLocalizedString(@"LanguageCode" , @"")]];
[self setImageWithURLRequest:[NSURLRequest requestWithURL:url]
placeholderImage:placeholderImage
success:nil
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){
safeSelf.image = [UIImage imageNamed:[NSString stringWithFormat:@"placeholderpic_%@_missing.png", NSLocalizedString(@"LanguageCode" , @"")]];
}
];
}else{
self.image = [self missingImage];
}
}
现在,可以在设置imageView
url
之后检查它。像NSLog(@"%@", self.imageView.usingURL)
。我想检查它是否与使用条件的另一个url
相同。像这样:
if(self.imageView.usingURL == [NSURL URLWithString:[trip.destination getHeaderImageUrl]])
使用此类别在UIImageView中添加属性
@interface UIImageView (URLImageView)
@property NSURL* usingURL;
@end
@implementation UIImageView (URLImageView)]
@end
现在下载图像并设置为图像视图时,将URL分配给图像视图,如
self.imageView.usingURL = yourURL
现在您可以访问此URL进行比较。