如何查看 URL 图片设置的内容?
How do I check what URL an image has been set with?
我使用 url
设置 image
,如下所示:
[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 进行比较。
我使用 url
设置 image
,如下所示:
[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 进行比较。