简体   繁体   中英

IOS: Disable scroll of a superview in IOS

All I am working on a legacy code that does the following

  1. creates a child view controller and add's it to the parent controller
  2. The child view controller is presented in the parent VC. So the animation starts from bottom towards the top, but only up to a specific location, leaving a height of 100 from the top.
  3. So I have a superview being displayed within the bounds (0,0), to (SCREEN_WIDTH, 0) and (0, 100) and (SCREEN_WIDTH, 100)
  4. The child view controller view is displayed below it.
  5. If you tap on any part of the screen that is a part of the parent view, you can swipe and up down, causing it to scroll. I don't want that. How do I disable scrolling of the superview when the child view is loaded?

I have tried the following solutions.

  1. Create a delegate protocol that parent VC implements to try to set the content off set to CGPointZero. This delegate is called from the child view.
  2. Create a delegate protocol that parent VC implements and call the following function from the parent VC (which has a custom UIScrollView) that executes the following

     self.view.scrollEnabled=NO; 

This option did not work for me either. Is there any other way for me to do this?

Present a child view controllers view fully with clear color . Inside that view make a subview by doing like this " but only up to a specific location, leaving a height of 100 from the top." so nothing is touchable from the parent's view. Or do what ever your doing ,but when child is about to present disable parent controller view with user interaction enable to 'NO' or cover it with clear color view.When child is diss missed enable the parent controllers view or remove that cover view.

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