暂时禁用用户与 ViewController 的交互 [英] Disable User Interaction with a ViewController temporarily

查看:23
本文介绍了暂时禁用用户与 ViewController 的交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用主视图控制器和导航视图控制器.如果用户使用导航,则导航视图控制器占据屏幕的 80%,主视图控制器占据另外 20%.在这种情况下,用户不应与主 ViewController 交互.

I use a Main ViewController and a Navigation ViewController. If the user uses the Navigation, the Navigation ViewController takes 80% of the Screen and the Main ViewController the other 20%. In this Case the user shouldn't interact with the Main ViewController.

如何暂时禁用与 Main ViewController 的交互?

How could i disable the interaction with the Main ViewController temporarily?

这声明了进一步的问题:

This declares the further Problems:

这部分工作正常.现在,如果导航处于打开状态,用户将无法与 MainViewController 交互,但这会产生另外两个问题:

This works partially fine. Now the User can't interact with the MainViewController if the Navigation is open, but this generates 2 other Problems:

问题:用户可以在 MainView 的位置(右侧 20% 的 App)与 NavigationView 进行交互.用户不应该进行值得较低 NavigationController (Navigation) 的交互

Problem: The User can interact with NavigationView at the place (20% of the App on the right side) of the MainView. The user shouldn't do an interaction worth the lower NavigationController (Navigation)

问题:用户无法在 MainView 的 20% 上拖动以关闭 NavigationView 并完整地打开 MainView.

Problem: The User can't drag on the 20% of the MainView to close the NavigationView and open the MainView complete.

我认为这可能是禁用与所有在 MainView 下分层的对象的交互的原因.如果我在另一个 ViewController 的函数中执行此操作,这可能吗?困难在于,我应该为不同类型的MainViews"执行此操作.有时它只包含一个 TableViewController,有时它包含一组 UIButton,等等.

I think it could be a reason to disable the interaction with all Objects with be hierarchical under the MainView. Is this possible if i do this in a function of another ViewController? The difficulty is, that i should do this for different kinds of "MainViews". Sometimes it includes only a TableViewController, sometimes its a cluster of UIButtons, and so on.

推荐答案

mainViewController.view.userInteractionEnabled = NO 应该适合你.

这会关闭视图对触摸的响应.

This shuts off the view from responding to touches.

这篇关于暂时禁用用户与 ViewController 的交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆