0

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 }

2013fyp
  • 11
  • 3
  • http://stackoverflow.com/questions/10015450/uigesture-recognition-on-different-areas-of-a-uiimageview – iPatel Mar 12 '13 at 06:57

2 Answers2

1

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.

Baby Groot
  • 4,637
  • 39
  • 52
  • 71
1

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. 
   }
 }
}
Balu
  • 8,470
  • 2
  • 24
  • 41
  • hi sunny, Thanks for the code. Do you know how to zoom in to a clicked point on the image? – 2013fyp Mar 13 '13 at 05:13
  • if you are getting answer for your question then accept that answer It helps clean up the community. Thanks! – Balu Mar 13 '13 at 11:01