UIScrollView zoomToRect not working
I have a UIScrollView开发者_运维技巧 with pagingEnabled on and I want to (using like a button or something) animated(ly) zoom to each page. I am using zoom to rect, but that's not working. Please help.
Try to use - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
instead as you (probably) do not want to change view's zoom anyway.
Try the following to scroll a page
of the paged scroll view (assuming that all pages have equal width):
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
[scrollView scrollRectToVisible:frame animated:YES];
In my case, I had forgotten to connect the UIScrollView's delegate in the storyboard. Therefore zoomToRect did not work.
精彩评论