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

無論內(nèi)容大小如何,UIScrollView 都不會滾動

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

問題描述

我在 Interface Builder 中創(chuàng)建了一個 UIScrollView 并為其添加了子視圖,但我無法讓它滾動.我看過其他類似的問題,但我已經(jīng)適當(dāng)?shù)卦O(shè)置了我的 contentSize.事實(shí)上,我什至嘗試過設(shè)置非常大的 contentSize,但它沒有產(chǎn)生任何影響.我錯過了什么?注意 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:

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

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

推薦答案

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

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 的關(guān)于 Auto 的發(fā)行說明布局,我復(fù)制了有趣的部分(強(qiáng)調(diào)我的,在第三個要點(diǎn)):

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):

以下是有關(guān) UIScrollView 的自動布局支持的一些說明:

Here are some notes regarding Auto Layout support for UIScrollView:

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

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

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

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

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:

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

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.

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

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

相關(guān)文檔推薦

iOS - Using storyboard and autolayout to center the UIScrollView(iOS - 使用故事板和自動布局使 UIScrollView 居中)
get index or tag value from imageview tap gesture(從 imageview 點(diǎn)擊手勢獲取索引或標(biāo)簽值)
Clean autorotation transitions in a paging UIScrollView(清除分頁 UIScrollView 中的自動旋轉(zhuǎn)轉(zhuǎn)換)
UIScrollView zooming with Auto Layout(UIScrollView 使用自動布局縮放)
How to create an image from a UIView / UIScrollView(如何從 UIView/UIScrollView 創(chuàng)建圖像)
iOS/Swift - Hide/Show UITabBarController when scrolling down/up(iOS/Swift - 向下/向上滾動時隱藏/顯示 UITabBarController)
主站蜘蛛池模板: 91不卡| 亚洲国产成人av好男人在线观看 | 91精品国产色综合久久 | 国产成人网 | 精品96久久久久久中文字幕无 | 国产日韩一区二区三区 | 精品精品 | 黄色一级大片在线免费看产 | 青青草免费在线视频 | 亚洲精品久久嫩草网站秘色 | 国产a视频 | 日韩欧美视频网站 | 午夜精品久久久久久久久久久久 | 国产精品高潮呻吟久久 | 97av视频在线观看 | 欧美日韩精品中文字幕 | 99在线免费观看视频 | 久久精品久久久久久 | 国产精品亚洲精品 | 精品在线播放 | 337p日本欧洲亚洲大胆鲁鲁 | 久久精品欧美一区二区三区不卡 | 欧洲一级毛片 | 亚洲看片网站 | 亚洲一区二区三区免费在线观看 | 久久国际精品 | 亚洲第一福利视频 | 欧美成人性生活 | 国产精品国产三级国产aⅴ无密码 | 国产精品一区二区三区在线 | 毛片在线免费播放 | 亚洲国产一区二区视频 | 99视频网 | 成人在线免费网站 | 国产一区二区精品自拍 | 国产精品看片 | 国产精品一区二区久久 | 欧美成人影院 | 精品欧美乱码久久久久久 | 欧美精品一区二区在线观看 | 中文字幕精品一区 |