Note that there are some explanatory texts on larger screens.

plurals
  1. POScrollView In Page Controller
    primarykey
    data
    text
    <p>I try to make an Image Gallery that supports zoom abilities. I choose to place every image into a scrollView of a ViewController that is used as a page of PageController. This is the initial pic of ViewController.</p> <p><img src="https://i.stack.imgur.com/LcxBy.png" alt="initial"></p> <p>When i zoom in the result is fine too.</p> <p><img src="https://i.stack.imgur.com/tqq8i.png" alt="zoom in picture"></p> <p>Although, if i zoom in and change one page and get back ,controller has a bad behaviour. It seems that something is remaining from the previous action into scrollView and i cannot find what.The image below is the false.</p> <p><img src="https://i.stack.imgur.com/t2WQz.png" alt="false image"></p> <p>I want to have the initial view again(Pic1)</p> <p>These methods handle the events.</p> <pre><code>- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.imageView = [[UIImageView alloc] initWithImage:image]; CGRect lala=(CGRect){.origin=CGPointMake(0.0f, 0.0f), .size=image.size}; [self.imageView setFrame:lala]; //[self.scrollView setFrame:CGRectMake(0, 65, 320, 520)]; [self.scrollView addSubview:self.imageView]; self.imageView.userInteractionEnabled=YES; // Tell the scroll view the size of the contents [self.scrollView setContentSize: image.size]; // Set up the minimum &amp; maximum zoom scales CGRect scrollViewFrame = self.scrollView.frame; CGFloat scaleWidth = scrollViewFrame.size.width / self.scrollView.contentSize.width; CGFloat scaleHeight = scrollViewFrame.size.height / self.scrollView.contentSize.height; CGFloat minScale = MIN(scaleWidth, scaleHeight); self.scrollView.minimumZoomScale = minScale; self.scrollView.maximumZoomScale = 1.0f; self.scrollView.zoomScale = minScale; //[self.scrollView setFrame:self.imageView.frame]; [self.scrollView setFrame:CGRectMake(0, 65, 320, 500)]; [self centerScrollViewContents]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; NSLog(@"Will"); self.imageView = [[UIImageView alloc] initWithImage:image]; //self.scrollView=[[UIScrollView alloc] init]; CGRect lala=(CGRect){.origin=CGPointMake(0.0f, 0.0f), .size=image.size}; [self.imageView setFrame:lala]; [self.scrollView setFrame:CGRectMake(0, 65, 320, 500)]; //[self.scrollView setFrame:self.imageView.frame]; //[self.scrollView addSubview:self.imageView]; self.imageView.userInteractionEnabled=YES; // Tell the scroll view the size of the contents [self.scrollView setContentSize: image.size]; } - (void)centerScrollViewContents { CGSize boundsSize = self.scrollView.bounds.size; CGRect contentsFrame = self.imageView.frame; if (contentsFrame.size.width &lt; boundsSize.width) { contentsFrame.origin.x = (boundsSize.width - contentsFrame.size.width) / 2.0f; } else { contentsFrame.origin.x = 0.0f; } if (contentsFrame.size.height &lt; boundsSize.height) { contentsFrame.origin.y = (boundsSize.height - contentsFrame.size.height) / 2.0f; } else { contentsFrame.origin.y = 0.0f; } self.imageView.frame = contentsFrame;} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload