Search code examples
iphoneuiscrollviewzoominguiscrollviewdelegatepinch

I want to zoom in and zoom out in ScrollView. How's it possible?


I have a scroll view within one image. I just want to zoom in and zoom out the scroll view. How do I apply zoom in and and zoom out just by doing the pinch?


Solution

  • Just add the file http://www.4shared.com/dir/-PGqZEXR/zoominzoomout.html to your project and call it through these functions.

    Here im2 is UIVIEW, and I paste the image on it then passing this through viewDidLoad like this,

    - (void)viewDidLoad {
        [self loadFlowersInView:im2];
        [self.view addSubview:im2];
    }
    

    Now attach this function like this,

    - (void) loadFlowersInView: (UIView *) backdrop
    {
        NSString *create_button = nil;
        // Add the flowers to random points on the screen
        for (int i = 0; i < 1; i++)
        {
                MagPicAppDelegate *appdelegate = (MagPicAppDelegate *)[[UIApplication sharedApplication] delegate];
    
                NSString *whichFlower = appdelegate.imageName;
                UIImage *stemp = [UIImage imageNamed:@"approve.png"];
                DragView *dragger = [[DragView alloc] initWithImage:stemp];
                dragger.userInteractionEnabled = YES;
                dragger.center = CGPointMake(160.0f, 140.0f);
                [im2 addSubview:dragger];
                [dragger release];
            }
        }
        [self.view  addSubview:im2];
        [im2 release];
    }