开发者

Multiple Tags on a UIImageView?

Is it possib开发者_C百科le to have more than one tag associated with a UIImageView ?

Cheers,

Martin


No, tag is just a single property and it's just an integer at that. You could always decide to encode the integer using bitwise OR or something, then AND it with a mask and bit shift to get more than one value out of it. In other words, use bitfields.


The tag serves solely to identify a view within your application. It's kind of like the id attribute in an HTML element; it doesn't make sense to have more than one of them attached to a single view. Use your own data structures to map tags to multiple "things" if you need to.


You can use NSMutableDictionary to map your UIImageView with another object. You need to use [NSValue valueWithNonretainedObject:yourView] as the key, and you can create 2 dictionary if you need to map 2 values. Note that the object is not retained, so you should release this dictionary when you are going to release your UIImageView instances.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜