Wesley Ow Wesley Ow - 5 months ago 346x
Swift Question

UIButtons at the bottom of UIScrollView not working

I created a UIScrollView in my storyboards and have added 12 UIButtons in a container View which is inside the UIScrollView.

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.

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.

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.

I am using autolayout.

I have tried fiddling with the contentSize of the UIScrollView and it does not help.


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.