I have a view with an imageview and a tableview below it. The imageview contains an image of a human body. Now what I’d like to do is to separate the image into three portions: The head, the thorax and the abdominal cavity. The tableview also has three rows, each corresponding to the sections of the body mentioned above.When I select or click any of these regions I want to scroll through the corresponding rows of the table and navigate to another viewcontroller which will serve as a detail view controller. So let’s say I choose head, I want to navigate to another page that explains head in detail. I get the same effect when I select any of the rows.
Share
You can easily do this using a
UITapGestureRecognizerinstance attached to the image view. First off, you will have to set theUIImageView‘suserInteractionEnabledtoYES. After attaching the gesture recognizer, you should resolve the touch to its region in the gesture handler.Now resolution is based on how you will define the regions. If they are just rectangles, declare three
CGRectobjects as instance variables and set them appropriately and do something like this,Or if the regions are a bit more complicated, use
UIBezierPathorCGPathRef.