问题描述:

I'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.

网友答案:

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.

网友答案:

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.

相关阅读:
Top