I am having difficulty figuring out why Erica Sadun does the following (calling viewDidAppear in viewDidLayoutSubviews) in her cookbook example Ch07-11. Perhaps the two methods should be calling another method instead?
See: https://github.com/erica/iOS-5-Cookbook/tree/master/C07
- (void) viewDidAppear:(BOOL)animated
{
scrollView.frame = self.view.bounds;
scrollView.center = CGRectGetCenter(self.view.bounds);
if (imageView.image)
{
float scalex = scrollView.frame.size.width / imageView.image.size.width;
float scaley = scrollView.frame.size.height / imageView.image.size.height;
scrollView.zoomScale = MIN(scalex, scaley);
scrollView.minimumZoomScale = MIN(scalex, scaley);
}
}
- (void) viewDidLayoutSubviews
{
[self viewDidAppear:NO];
}
Any idea why?
because layout srollView in viewDidLayoutSubviews will change scrollView which you had setted up.Then, scrolling scrollView should get little stutters.