CIMinuv
CIMinuv

Reputation: 3

Detecting touches on a UIImageView in IPhone

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.

Upvotes: 0

Views: 167

Answers (2)

Deeps
Deeps

Reputation: 4577

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.

Upvotes: 1

Ilanchezhian
Ilanchezhian

Reputation: 17478

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.

Upvotes: 0

Related Questions