Gajendrasinh Chauhan
Gajendrasinh Chauhan

Reputation: 3397

Zooming and TapGesture in iphone

How to add zooming (using pinch gesture) and touch (using tapGesture) in UIImageView without using scrollView? Is it possible? I have used both UIImageView and UIScrollView.This is my code placed on viewDidLoad.

    [scrollView addSubview:imgView];
    scrollView.minimumZoomScale = 1.0;
    scrollView.maximumZoomScale = 12.0;
    scrollView.delegate = self;

    [scrollView setZoomScale:scrollView.userInteractionEnabled];
    [[self view] addSubview:imgView];

    [scrollView bringSubviewToFront:self.view];



//gesture recognizer
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
    [imgView addGestureRecognizer:tap];

If I try this code.Works fine with Tap but zooming doesn't work because Imageview hides scrollview.Is there any idea, How to add both zooming and touch functionality on UIImageview?

Thanks.

Upvotes: 0

Views: 790

Answers (1)

The iOSDev
The iOSDev

Reputation: 5267

it is possible to add both zooming and tap gestures on uiimage view just see this code i have found on net this will help you with what you need. Enjoy Codding ;)

Upvotes: 1

Related Questions