Hallo Zusammen,
ich habe folgendes Problem mit einem ScrollView:
Ein Bild mit 640 x 1536 Pixel ist im Imageview, Containerview, Scrollview.
Zu Anfang kann ich Scrollen und Zoomen. Nach dem ersten Zoomen kann ich nur noch zoomen aber nicht mehr scrollen.
Im Storyboard: View - Scrollview - Containerview - Imageview
Da hab ich doch bestimmt was vergessen?
Alles anzeigen
ich habe folgendes Problem mit einem ScrollView:
Ein Bild mit 640 x 1536 Pixel ist im Imageview, Containerview, Scrollview.
Zu Anfang kann ich Scrollen und Zoomen. Nach dem ersten Zoomen kann ich nur noch zoomen aber nicht mehr scrollen.
Im Storyboard: View - Scrollview - Containerview - Imageview
Da hab ich doch bestimmt was vergessen?
Quellcode
-
- - (void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
- [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
- [self.view addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
- NSString *bildPfad;
- bildPfad = [[NSBundle mainBundle] pathForResource:@"Bild" ofType:@"png"];
- self.image = [[UIImage alloc]initWithContentsOfFile:bildPfad];
- self.imageView.image = [UIImage imageWithCGImage:[self.image CGImage] scale:(self.image.scale * 1.0) orientation:(self.image.imageOrientation)];
- [self.imageView setFrame:CGRectMake(0, 0, self.image.size.width, self.image.size.height)];
- [self.containerView setFrame:CGRectMake(0, 0, self.image.size.width, self.image.size.height)];
- self.scrollView.contentSize = self.containerView.frame.size;
- self.scrollView.minimumZoomScale = (self.view.frame.size.width / self.image.size.width) ;
- self.scrollView.maximumZoomScale = 2.0;
- self.scrollView.zoomScale = self.scrollView.minimumZoomScale;
- [self.scrollView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
- }
- - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
- {
- return self.containerView;
- }