简体   繁体   English

UIScrollView:仅向左水平分页,向右跳动

[英]UIScrollView : only paging horizontally left, bouncing right

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)? 如何强制启用分页和滚动功能的UIScrollView只向左水平移动或沿两个方向(左右)水平移动?

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. 我想知道解决方案是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??
}

} }

I'd implement the delegate function scrollViewDidScroll: and store the state (scroll state) of the ScrollView. 我将实现委托函数scrollViewDidScroll:并存储ScrollView的状态(滚动状态)。 On subsequent calls, compare with the previous state and have it bounce back (by calling ZoomToRect: maybe) if it is in a particular direction that you don't like. 在随后的通话中,如果您不喜欢某个特定方向,则将其与以前的状态进行比较,并使其反弹(通过调用ZoomToRect:也许)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM