久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

無論內容大小如何,UIScrollView 都不會滾動

UIScrollView not scrolling regardless of large contentSize(無論內容大小如何,UIScrollView 都不會滾動)
本文介紹了無論內容大小如何,UIScrollView 都不會滾動的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在 Interface Builder 中創建了一個 UIScrollView 并為其添加了子視圖,但我無法讓它滾動.我看過其他類似的問題,但我已經適當地設置了我的 contentSize.事實上,我什至嘗試過設置非常大的 contentSize,但它沒有產生任何影響.我錯過了什么?注意 UIScrollView 是一個 IBOutlet:

I have created a UIScrollView and added subviews to it in Interface Builder, but I am not able to get it to scroll. I have looked at other similar questions, but I have set my contentSize appropriately. In fact, I have even tried setting incredibly large contentSize and it fails to make a difference. What am I missing? Note that the UIScrollView is an IBOutlet:

@property (strong, nonatomic) IBOutlet UIScrollView *scroll;

這是在我看來DidLoad:

This is in my viewDidLoad:

self.scroll.scrollEnabled = YES;
[self.scroll setContentSize: CGSizeMake(2400,8000)];

這是來自 Interface Builder 的屏幕截圖:

Here are screenshots from Interface Builder:

這是運行時的視圖,但在任何時候水平或垂直滾動??的任何嘗試都不起作用.

Here is the view while running, but any attempt at horizontal or vertical scrolling at any point does not work.

推薦答案

關閉自動布局可以,但這不是解決方案.如果你真的需要Auto Layout,那就使用它,如果你不需要它,把它關掉.但這不是此解決方案的正確解決方案.

Turning Auto Layout off works, but that's not the solution. If you really need Auto Layout, then use it, if you don't need it, turn it off. But that is not the correct fix for this solution.

UIScrollView 與自動布局中的其他視圖不同.這是 Apple 的關于 Auto 的發行說明布局,我復制了有趣的部分(強調我的,在第三個要點):

UIScrollView works differently with other views in Auto Layout. Here is Apple's release note on Auto Layout, I've copied the interesting bit (emphasis mine, at third bullet point):

以下是有關 UIScrollView 的自動布局支持的一些說明:

Here are some notes regarding Auto Layout support for UIScrollView:

  • 通常,自動布局將視圖的頂部、左側、底部和右側邊緣視為可見邊緣.也就是說,如果您將視圖固定到它的超級視圖的左邊緣,你真的把它固定在超級視圖邊界的最小 x 值.更改邊界原點父視圖的位置不會改變視圖的位置.
  • UIScrollView 類通過更改其邊界的原點來滾動其內容.為了使這項工作與自動布局一起使用,頂部、左側、底部、滾動視圖中的右邊緣現在意味著其內容的邊緣查看.
  • 對滾動視圖的子視圖的約束必須導致要填充的大小,然后將其解釋為滾動視圖的內容大小滾動視圖.(這不應與用于自動布局的 intrinsicContentSize 方法.)調整滾動的大小具有自動布局的視圖框架,約束必須是顯式的關于滾動視圖的寬度和高度,或滾動視圖必須綁定到其子樹之外的視圖.
  • 請注意,您可以通過創建約束使滾動視圖的子視圖看起來浮動(不滾動)在其他滾動內容之上在視圖和滾動視圖的子樹之外的視圖之間,例如滾動視圖的超級視圖.

Apple 然后繼續展示如何正確使用 UIScrollView 和 Auto Layout 的示例.

Apple then goes on to show example of how to correctly use UIScrollView with Auto Layout.

作為一般規則,最簡單的解決方法之一是在元素到 UIScrollView 底部之間創建一個約束.因此,在您希望位于 UIScrollView 底部的元素中,創建此底部空間約束:

As a general rule, one of the easiest fix is to create a constraint between the element to the bottom of the UIScrollView. So in the element that you want to be at the bottom of the UIScrollView, create this bottom space constraint:

再一次,如果您不想使用自動布局,請將其關閉.然后,您可以按通常的方式設置 contentSize.但你應該明白,這是 Auto Layout 的預期行為.

Once again, if you do not want to use Auto Layout, then turn it off. You can then set the contentSize the usual way. But what you should understand is that this is an intended behaviour of Auto Layout.

這篇關于無論內容大小如何,UIScrollView 都不會滾動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

iOS - Using storyboard and autolayout to center the UIScrollView(iOS - 使用故事板和自動布局使 UIScrollView 居中)
get index or tag value from imageview tap gesture(從 imageview 點擊手勢獲取索引或標簽值)
Clean autorotation transitions in a paging UIScrollView(清除分頁 UIScrollView 中的自動旋轉轉換)
UIScrollView zooming with Auto Layout(UIScrollView 使用自動布局縮放)
How to create an image from a UIView / UIScrollView(如何從 UIView/UIScrollView 創建圖像)
iOS/Swift - Hide/Show UITabBarController when scrolling down/up(iOS/Swift - 向下/向上滾動時隱藏/顯示 UITabBarController)
主站蜘蛛池模板: 精品久久视频 | 操欧美女人 | 天天干天天操天天 | 免费成人小视频 | 中文字幕免费在线观看 | 亚洲激情中文字幕 | 成人看片网 | 久久99精品久久久久久 | 手机av在线免费观看 | 久久av免费 | 黄色免费大片 | 精品蜜桃一区二区三区 | a视频在线观看 | 偷拍一区二区三区 | 快播少女爱欢乐 | 日韩视频一区 | 成人在线观看网站 | www.成人网| 一区二区免费 | 国产精品久久久久永久免费看 | 91免费版看片 | 欧美区在线 | 天天澡天天狠天天天做 | 超碰99在线 | 国产一级一片免费播放放a 国产黄色大片 | 青青草在线观看视频 | a视频| 国产在线成人 | 欧美日韩黄色片 | 在线观看国产小视频 | 亚洲高清视频在线观看 | 国产区视频 | 波多野结衣一区二区三区在线观看 | 日本一区二区三区在线视频 | 久视频在线| 伊人精品 | 午夜在线免费视频 | 国产精品美女久久久 | 日本中文字幕在线视频 | 日韩精品三区 | 国产三级在线 |