开发者

Detecting touches on a UIImageView in IPhone

I'开发者_StackOverflow中文版m programming a King Chess game on the iPhone. When the user touches a square on the screen, I want to know which square was selected.

I am using UIImageViews to show squares on the screen.


UIImageview would not be feasible in your scenario. You can use UIButton with customtype and assign image to that button. So it looks like button but you can add target and you know which square touch/pressed.

Hope this help.


in touchesEnded: method , u can get the position of ur touch. Then , u go thru all the image views (squares) , comparing their frame positions using CGRectIntersectsRect and find which square is touched.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜