iPhone開發筆記(14)UIScrollView的邊界處理問題

來源:互聯網
上載者:User

  在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。就是在滑動到最左端的圖片時,再向左滑動就滑動不了,向右滑動也是一樣的道理。這樣就解決了數組越界所導致的崩潰問題。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.