UIScrollView :仅水平向左分页,向右弹跳
如何强制启用分页和滚动的 UIScrollView 仅水平向左或水平两个方向(左和右)移动?
更清楚地说,我想允许用户在给定时刻“仅水平向后翻页(仅当用户尝试向右水平滚动时弹跳)”或“水平双向(这是正常操作)”。
我想知道解决方案是 UIScrollView 的子类。
提前致谢。
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if ( only bounce.. ){
// is it right?
if (scrollView.contentOffset.y > 60) {
[scrollView setContentOffset:CGPointMake(0, 60)];
}
}
if ( only paing left... ){
How to do this??
}
}
How can I force a UIScrollView in which paging and scrolling are on to only move horizontally left or horizontally both direction(left and right)?
To be clearer, I'd like to allow the user to 'page only horizontally backward(only bounce when the user try to scroll horizontally right)' OR 'horizontally both direction(this is normal action)' at a given moment.
I am wondering that the solution is the subclass of UIScrollView.
Thanks in advance.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if ( only bounce.. ){
// is it right?
if (scrollView.contentOffset.y > 60) {
[scrollView setContentOffset:CGPointMake(0, 60)];
}
}
if ( only paing left... ){
How to do this??
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将实现委托函数
scrollViewDidScroll:
并存储 ScrollView 的状态(滚动状态)。在后续调用中,与之前的状态进行比较,如果它处于您不喜欢的特定方向,则将其反弹(可能通过调用 ZoomToRect: )。I'd implement the delegate function
scrollViewDidScroll:
and store the state (scroll state) of the ScrollView. On subsequent calls, compare with the previous state and have it bounce back (by callingZoomToRect:
maybe) if it is in a particular direction that you don't like.