以分步增量滚动水平UIScrollView? [英] Scrolling a horizontal UIScrollView in stepped increments?

查看:147
本文介绍了以分步增量滚动水平UIScrollView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以水平滚动的UIScrollView。



有一种方法让滚动只以分步增量而不是像素(即每次移动列)的方式移动。

图表:

解决方案

有:

  yourScrollView.pagingEnabled = YES; 

检查 UIScrollView 了解更多信息。


的属性是YES,滚动视图停止在滚动视图的边界的倍数,当用户滚动。默认值为NO。


我建议您可能需要将视图结构更改为:

  + -------- + 
| | < - UIView来保存你的结构
+ -------- +

+ - +
| | < - UIScrollView,clipsToBounds = NO,width = column.width
+ - +

+ - + - + - +
| | | | < - UIView columns
+ - + - + - +

UIScrollView 水平并确保包含 UIScrollView UIView >的宽度是 UIScrollView


的宽度的倍数

I have a UIScrollView that can be scrolled horizontally. The scrollable content is displayed in columns.

Is there a way to make the scrolling only move in stepped increments instead of pixels (i.e. move a column at a time).

Diagram:

解决方案

Yup there is:

yourScrollView.pagingEnabled = YES;

Check the UIScrollView for more information.

If the value of this property is YES, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. The default value is NO.

I suggest you may need to change your view structure to something like this:

+--------+
|        | <- UIView to hold your structure
+--------+

   +--+
   |  |    <- UIScrollView, clipsToBounds = NO, width = column.width
   +--+

+--+--+--+
|  |  |  |  <- UIView columns
+--+--+--+

Center the UIScrollView horizontally and make sure that the UIView that contains the UIScrollView has a width that is a multiple of the width of the UIScrollView

这篇关于以分步增量滚动水平UIScrollView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆