开发者

Get Index of Object in TouchesEnded

i have a UIViewController with many UIImageViews. I ne开发者_JAVA技巧ed in touchEnded event get a index of this UIimage.

How do Make?

Thank's


make a custom UIImageview class which is subclass of UIControl. and add a target method for this class.set the tag for each UIImageview. and change the class name of UIImageview in inspector window to that custom class.

[imageview addTarget: self action:@selector(findIndex:)forControlEvents:UIControlEventTouchUpInside ]

you can set this method using xib also. and define findIndex method in your viewController class.


Instead of UIImageViews, why don't you use UIButtons? You can set the image with setImage:forState:, and the target action and object with addTarget:action:forControlEvents. When your target action gets called, the button will be sent as the sender argument.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜