UIButtons and UITextViews not working in Scrollview

Multi tool use
UIButtons and UITextViews not working in Scrollview
So I have a scrollview with a view inside. In this view I have several textviews and buttons. When I run the app, it will scroll, but I cannot click the buttons or insert text into the textviews. I have checked for multiple solutions online and have yet to find one. I have already allowed user interaction on everything. I have disabled the click delay. I am running out of ideas here.
Have you tried using the Debug View Hierarchy to check if there is something else blocking the textview and buttons?
– mn1
Jun 30 at 23:28
please share your code or more information about your project, otherwise it won´t be possible to help you solve the problem
– DevB2F
Jul 1 at 21:58
2 Answers
2
try this:
for subview in self.scrollView.subviews {
print(subview)
print(subview.frame)
print(subview.isUserInteractionEnabled)
}
make sure all of them have userinteraction enabled.
The contentView of the scrollView might not have userinteraction enabled.
By printing out the frame for each subview you can see if any views are overlapping, which might be causing the problem.
You must set:
viewInsideScrollView.isUserInterationEnabled = true
viewInsideScrollView.isUserInterationEnabled = true
Sure your buttons, textfields and scrollviews have userInteraction enabled but this is useless if any superview of the control you are interested in isn't allowing interaction. Its like a protective parent putting a glass screen between you and its child.
I tested this by putting a button inside an imageView and this was the difference between it working and not. I can supply the code for this view if you would like to play with it.
Already have done that
– Dylan Snyder
Jul 1 at 6:20
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
share code or better a demo of what you have tried
– Sh_Khan
Jun 30 at 23:06