有时候我们使用ImageView的时候 想要知道现在的显示的图片是placeHolder的图片还是加载完成或挑选好的图片,但是tag属性只能拿到却不能判断,当然,加几个bool属性也可以完成,但是会有些复杂,如果可以在给imageview 赋图片的时候给图片加个标记,那么下次判断一下标记是不是placeHolder就可以了,很简单。
UIImageView * picView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 90, 50, 50)];
picView.layer.cornerRadius = 3;
picView.userInteractionEnabled = YES;
picView.layer.masksToBounds = YES;
picView.image = [UIImage imageNamed:@"add_pic.png"];
[picView.image setAccessibilityIdentifier:@"add”];
判断
if ([picView.image.accessibilityIdentifier isEqualToString:@"add"]) {
[self chooseImageFromAblum:^(UIImage *image) {
picView.image = image;
// 给新图片的AccessibilityIdentifier赋新值
[picView.image setAccessibilityIdentifier:@"new"];
}];
}else{
[self blowUpImageWithPic:picView.image];
}
这样会方便很多,减少bool变量过多带来的问题。
版权声明:本文为博主原创文章,未经博主允许不得转载。
image 的 AccessibilityIdentifier 属性的使用
原文地址:http://blog.csdn.net/tutuzhuz/article/details/47397235