Paging UIScrollView with different page widths

。_饼干妹妹 提交于 2019-11-28 19:33:32

it's surely possible, but not so automatically...

i guess you should implement the UIScrollViewDelegate protocol method:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{

}

it's the method called when the user stop to move the finger on the scrollView, you can check inside it the coordinate of your content:

yourScrollView.contentOffset

and then check which one of your page.x ( register them in an array when you create them, or check the origin of all your view added to the scrollView) is closer to it, then go to the offSet of your page (with animation) calling:

- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!