問題描述
我在我的故事板中創建了一個 UIScrollView,并在 UIScrollView 內的容器視圖中添加了 12 個 UIButton.
I created a UIScrollView in my storyboards and have added 12 UIButtons in a container View which is inside the UIScrollView.
在 iPhone 5s 模擬器上運行時,屏幕上可以看到 9 個按鈕,其余按鈕只有向下滾動才能看到.
when running on the iPhone 5s simulator, 9 of the buttons can be seen on the screen, the rest of the buttons only can be seen when you scroll down.
最初可以在屏幕上看到的 9 個按鈕可以與之交互.但是,滾動視圖底部的 3 個按鈕(必須滾動到才能看到)無法交互.
the 9 buttons that can be initially seen on the screen can be interacted with. However the 3 buttons at the bottom of the scroll view (which have to be scrolled to in order to be seen) cannot be interacted with.
我在 iPhone 6 模擬器上運行該應用程序,該模擬器無需滾動即可在屏幕上顯示所有 12 個按鈕,并且底部 3 個按鈕可以工作.
I ran the app on an iPhone 6 simulator which displays all 12 of the buttons on the screen without having to scroll and the bottom 3 buttons work.
我正在使用自動布局.
我曾嘗試擺弄 UIScrollView 的 contentSize,但它沒有幫助.
I have tried fiddling with the contentSize of the UIScrollView and it does not help.
推薦答案
看來你需要增加容器視圖的框架高度.scrollView 的 contentSize
只影響它的滾動方式,這里無關緊要.
It seems you need to increase the frame height of container view. The contentSize
of scrollView only affects how it will scroll, which is irrelevant here.
如果按鈕在容器視圖之外,它仍然會顯示.但是,它無法響應任何觸摸事件.
If the button is outside the container view, it will still show up. However, it can't respond to any touch event.
這篇關于UIScrollView 底部的 UIButtons 不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!