开发者

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 pageof 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜