开发者

Objective C Comparing the name of an UIImageView

i have a question, totally newbie but i would like to know how can i get to compare and image in an if else statement?

i have an image lets say it is 开发者_JAVA百科"img.png" and i have it displayed in an imageview already in the application, however in the codes i would like to compare if the image show is "img.png"

I understand that for string we use the isEqualToString:, so if it's for an image what would i use?

example would be :

if ([img.image isEqual:@"img.png"])

What i've typed is something like this but it isnt working. could anyone point me in the right direction? thanks alot

Much appreciated!


If you first got the image using [UIImage imageNamed:@"img.png"] you could compare the image object pointers: if (img.image == [UIImage imageNamed:@"img.png"]).

But: I'd consider this bad design and would rather use another way of identifying images, like storing the name of the image in another instance variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜