Objective-C:UIScrollView手动分页 [英] Objective-C : UIScrollView manual paging

查看:178
本文介绍了Objective-C:UIScrollView手动分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在水平模式下使用scrollview作为选择器。
scrollview最多可容纳7个子视图。
每个子视图代表一个值。
总是可以看到三个视图,中间的一个是选定的视图。

I want to use the scrollview as something like a picker in horizontal mode. The scrollview holds up to seven subviews. Each subview represents a value. Always three views are visible and the one in the middle is the selected one.

Scrollview在开始时可见:

Scrollview visible at start:

__ | V1 | V2

__ | V1 | V2

Scrollview设置为查看/值二:

Scrollview set to view/value two:

V1 | V2 | V3

V1 | V2 | V3

Scrollview设置为最后一个值:

Scrollview set to last value:

V2 | V3 | __

V2 | V3 | __

我遇到的真正问题是pagingEnabled标志。
如果pagingEnabled设置为YES,则scrollview页面总是三个子视图/值而不是一个。
如果将pagingEnabled设置为NO,则scrollview不会成功。

The real problem I have got is the "pagingEnabled" flag. If pagingEnabled is set to YES the scrollview pages always three subviews/values instead of only one. If pagingEnabled is set to NO the scrollview does not clinch.

我的问题是否有一个很好的解决方案?

Is there a nice solution for my problem?

非常感谢,
Dan;)

Thanks a lot, Dan ;)

推荐答案

将scrollview的框架更改为如果它只显示中间视图(即其原始宽度的三分之一,并偏移相同的数量),但然后将其 clipsToBounds 属性设置为NO。

Change the frame of the scrollview to be as if it were only displaying the middle view (i.e. a third of its original width, and offset by the same amount), but then set its clipsToBounds property to NO.

这篇关于Objective-C:UIScrollView手动分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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