I don't understand why the scrollview isn't working, because I followed advices from tutorials.
I created the UIScrollView
that contains an UIImageView
and I also added the method
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return imgv;
}
and the UIScrollViewDelegate
in the interface, but it isn't working.
Here is the code for the UIScrollView
:
imgv = [[UIImageView alloc]
initWithFrame:CGRectMake(0, 0, 1000, 500)];
imgv.image = [UIImage imageWithData:retrievedData];
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 800, 800)];
scrollView setContentSize:CGSizeMake(imgv.image.size.width, imgv.image.size.height)];
scrollView.maximumZoomScale = 4;
scrollView.minimumZoomScale = 1;
[scrollView setScrollEnabled:YES];
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(hideImageView)];
[scrollView addSubview:imgv];
[view addSubview:scrollView];
I would be thankful, if someone could figure out what the problem could be.