Reputation: 11
Hi i am trying to implement an application which allows user to click on certain part of the image, for example fish(fins, tails) and navigate to another page of xib to show the content of the parts. Do anyone know how to enable on click to images and pin point the various part for clicking? Please help! Thanks a lot!
P.S. i have found out how to click on the image and able to get the coordinates for the image. How do i use that coordinates in an if statement? For example,
if (location = i) { go this page }
else if (location = a) { go this page }
Upvotes: 0
Views: 115
Reputation: 8460
Try like this may be it helps you,
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint lastLocation = [touch locationInView: self.view];
if (![[touch view] isKindOfClass:[UIImageView class]]) {
if (lastLocation.x>103 & lastLocation.y<269) { //place your location points here
// keep you condition based on image view and push the view here.
}
}
}
Upvotes: 1
Reputation: 4279
If you have static image,
simplest way to achieve this is to add UIButton
with type custom, and then you add that over that image parts. Set background color and everything to clearcolor, so it would appear transparent.
On touchUpInside
event of that button, you can redirect it to other view.
Upvotes: 1