开发者

Detecting touches on a UIImageView in IPhone

开发者 https://www.devze.com 2023-03-19 20:07 出处:网络
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'开发者_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

精彩评论

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

关注公众号