IPhone : UIScrollView automatically scrolls down during pinch in?

on Wednesday, February 25, 2015

I have uiscrollview and added an image view to it. When I pinch in scroll view i can able to zoom in but the scroll view automatically scrolls down a bit. So that I'm not able to zoom the bottom portion of uiimageview.



UIScrollView *scroll = [[UIScrollView alloc]init];
scroll.minimumZoomScale = 1.0f;
scroll.maximumZoomScale = 16.0f;
scroll.delegate = self;

[scroll setContentSize:CGSizeMake(scroll.frame.size.width, scroll.frame.size.height+2200)];
scroll.frame = self.view.frame;
[scroll setBackgroundColor:[UIColor brownColor]];
[self.view addSubview:scroll];


UIImageView *img = [[UIImageView alloc]init];
[img setBackgroundColor:[UIColor yellowColor]];
[img setImage:[UIImage imageNamed:@"add_button.jpg"]];
[img setFrame:CGRectMake(0, 100, self.view.frame.size.width, 200)];
[img setContentMode:UIViewContentModeScaleAspectFit];
[scroll addSubview:img];



- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return [[scrollView subviews] firstObject];
}

0 comments:

Post a Comment