开发者

Pass touch events to one of multiple options

I've created a board of UIImageViews, that are held within a single object as an NSArray. all the imageviews are displayed as subviews of the 'board'(the object that holds the array). What I would like to do is when I touch any of the individual squares of the board (the imageviews) that the one that is touched is the one that picks up the event. Currently the board picks up all the touch events. pa开发者_JAVA百科ssing the touches automatically to nextResponder doesn't work, since there isn't a single nextResponder, but many, with a single one being the correct one.


By default, UIImageView overrides the value of the userInteractionEnabled property to NO (see http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImageView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIImageView/userInteractionEnabled). This is what is causing your UIImageViews to not receive touch events, and so they are accepted by the board superview.

To make it so your UIImageViews receive touch events, just set the userInteractionEnabled property to YES.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜