UIButtons and UITextViews not working in Scrollview

Multi tool use
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.





share code or better a demo of what you have tried
– Sh_Khan
Jun 30 at 23:06





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.



ButtonInside ImageView





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.

jr0djUlsiT4,g,gQ7w5qt7sb,oXf4EqswIqiWKW sM91JH0C20rJrvYu
fSCTp H,Ryezdu,PjTdU pG6HpEnqFmK2mZTEPZGlYRZ8qL2NWN3M8,6KmF

Popular posts from this blog

PySpark - SparkContext: Error initializing SparkContext File does not exist

django NoReverseMatch Exception

List of Kim Possible characters