iPhone开发笔记(14)UIScrollView的边界处理问题

    在iPhone开发笔记(5)scrollView和pageControl的搭配使用中忽略了UIScrollView的边界处理问题。在UIScrollView中有一个重要的属性bounces,下面是苹果的开发文档中对这个属性的定义。

bounces

A Boolean value that controls whether the scroll view bounces past the edge of content and back again.

@property(nonatomic) BOOL bounces
Discussion

If the value of this property is YES, the scroll view bounces when it encounters a boundary of the content. Bouncing visually indicates that scrolling has reached an edge of the content. If the value is NO, scrolling stops immediately at the content boundary without bouncing. The default value is YES.

Availability
  • Available in iOS 2.0 and later.

(1)当bounces属性设置为YES时,当UIScrollView中图片滑动到边界的时候会出现弹动的效果,就像是Linux中的果冻效果一样。

(2)当bounces属性设置为NO时,当UIScrollView中图片滑动到边界时会直接定在边界就不会有弹动的效果。


    我将bounces属性设置为NO,这样就解决了一个bug。就是在滑动到最左端的图片时,再向左滑动就滑动不了,向右滑动也是一样的道理。这样就解决了数组越界所导致的崩溃问题。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值