简体   繁体   中英

UIScrollView tap gesture not working

I have an application where I am creating and adding PrimaryViewController to a UIScrollView , when the user taps on a button on PrimaryViewController 's view, I create and add a SecondViewController to the UIScrollView . The SecondViewController creates and adds a new UIScrollView to it's view.

My problem is this: I need to get a tap event on the SecondViewController 's UIScrollView. But when I tap on the SecondViewController 's UIScrollView it throws an error (unrecognized selector). I believe it has to do with the view hierarchy and the fact that I am creating a new SecondViewController each time the button on PrimaryViewController 's view is tapped (which I need to do). Does anyone know how to solve this view-hierarchy issue? If you need more of an explanation let me know.

A friend helped me solve my issue. I was creating a new SecondViewController each time the PrimaryViewController's button was tapped. I changed it so I just update the data in the SecondViewController instead of creating an entirely new view controller. I still don't quite understand the problem, but will update this post if I figure out why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM