vinothp
vinothp

Reputation: 10069

How to make certain part of image clickable in ios?

In one of my app i am using image for the whole screen. Which can be zoomed to some extent. That image has eight different shapes(includes person,shapes,etc).What i am trying to do is i need to make certain each shape of the image is clickable. Touching each part takes to different screens.I didn't have any idea about how to achieve this. I googled it but no solution.

1.) Is this possible by using co-ordinates(will normal image and zoomed image differ in co-ordinates? How to achieve this by using co-ordinates?

2.) If not what will be the best approach to achieve my goal?

Any ideas/samples is much appreciated.

Upvotes: 0

Views: 830

Answers (3)

iTukker
iTukker

Reputation: 2083

I would add a UITapGestureRecognizer to the imageView holding your image. And the locationOfTouch:inView: method to determine the coordinates of your touch.

Upvotes: 1

Hyperbole
Hyperbole

Reputation: 3947

Check UIResponder and the touches methods in there. You'll probably want to hook in to something like -touchesEnded:withEvent: for detecting when a finger lifts off the screen.

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    for (UITouch *touch in touches) {
        CGRect touchLocationInView = [touch locationInView:imageView];
        // Do something to check that the rect is valid
        // If valid, react to it
    }
}

Also, a link to UITouch.

Upvotes: 0

brianLikeApple
brianLikeApple

Reputation: 4371

Correct me if i don't understand your question. For me, that should be very simple? Just have couple of buttons which background is clear? And They are all on top of the image.

Upvotes: 0

Related Questions