Use of the Accessibilityidentifier property of the image

Source: Internet
Author: User

Sometimes we want to know when we use ImageView to see whether the image displayed is placeholder or loaded or selected, but the Tag property can only be obtained but cannot be judged, of course, plus a few bool attributes may be done, but it will be somewhat complex, If you can assign a picture to the ImageView to add a marker, then the next time to determine whether the mark is placeholder on it, very simple.


uiimageview * picview = [[ uiimageview alloc] initWithFrame : Cgrectmake ( 10 90 50 50

picview. Layer. Cornerradius =3;

picview. userinteractionenabled =YES;

picview. Layer. Maskstobounds =YES;

picview. Image = [UIImageimagenamed:@ "Add_pic.png"];

    [ picview image Setaccessibilityidentifier Span style= "Color:rgb (243,55,38); Font-family:menlo; Font-size:24px ">@" add " ";



The image "Add_pic.png" is labeled "Add", and when you change the image of Picview, the value of this property becomes null if you do not re-copy the Accessibilityidentifier property. Each image corresponds to an exclusive accessibilityidentifier, which allows us to identify the image.

Judge

if ([picview. Image. Accessibilityidentifierisequaltostring:@ "Add"]) {

[ self chooseimagefromablum: ^ (UIImage *image) {

Picview. image = image;

assign a new value to a new picture's accessibilityidentifier

[picview. Image setaccessibilityidentifier:@ "new"];

}];

}Else{

[self blowupimagewithpic:picview. Image ];

}



This makes it much easier to reduce the problem caused by too many bool variables.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Use of the Accessibilityidentifier property of the image

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.