简体   繁体   English

iOS:在IOS中禁用超级视图滚动

[英]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. 子视图控制器显示在父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. 因此,动画从底部开始向顶部开始,但仅到特定位置为止,从顶部离开高度为100。
  3. So I have a superview being displayed within the bounds (0,0), to (SCREEN_WIDTH, 0) and (0, 100) and (SCREEN_WIDTH, 100) 所以我有一个超级视图显示在(0,0)到(SCREEN_WIDTH,0)和(0,100)和(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. 创建父VC实施的委托协议,以尝试将内容设置为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 创建父VC实现的委托协议,并从父VC(具有自定义UIScrollView)中调用以下函数,以执行以下操作

     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." 在该视图内,可以像这样“创建子视图”,但只能到特定位置,离顶部的高度为100。 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. 或执行您所做的任何操作,但是当子级将要呈现时,禁用父控制器视图,并且用户交互将其设置为“否”,或者用清晰的颜色视图覆盖它。当子级缺失时,请启用父控制器视图或删除该封面视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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