IOS開發,autolayout中uiscrollview的因爲contentsize的引發的問題

經過翻閱衆多資料,雖然有很多的解決方案,可是當實際操做過程當中,發現只有一個方法有用,參考網址:http://stackoverflow.com/questions/19036228/uiscrollview-scrollable-content-size-ambiguity-xcode-5-ios-7-interface-builder ios

解決方案爲:git

So I just sorted out in this way:github

  1. Add in the UIScrollView a UIView (we can call that contentView);segmentfault

  2. In this contentViewset top, bottom, left and right margin to 0 (of course from the scrollView which is the superView); Set also align center horizontally and vertically;xcode

Finished.ui

Now you can add all your view in that contentView, and the contentSize of the scrollView will be automatically resized according with the contentView.this

一個外國網友對於該問題的回答。親測可行,而且將 Set also align center horizontally and vertically;改爲equal width 和 equal height也可行,spa

具體其餘參考網頁如:http://stackoverflow.com/questions/15773815/storyboard-uiscrollview-contentsizecode

http://segmentfault.com/blog/lingchen/1190000002462033 orm

http://grayluo.github.io/WeiFocusIo/autolayout/2015/01/27/autolayout3/

http://stackoverflow.com/questions/19036228/uiscrollview-scrollable-content-size-ambiguity-xcode-5-ios-7-interface-builder

相關文章
相關標籤/搜索