【问题标题】:Disabling user interaction with a UIBarButtonItem禁用与 UIBarButtonItem 的用户交互
【发布时间】:2012-08-15 17:40:34
【问题描述】:

当我的应用程序运行一个简短的动画时,我不希望用户能够点击任何东西。在我的视图控制器中,我可以使用

    self.view.userInteractionEnabled = NO;

阻止大多数交互,但不会阻止工具栏/导航栏中的按钮触发事件。

我不能只禁用按钮,因为这会分散视觉影响(按钮变灰)。

如何暂时暂停与所有控件的交互?

【问题讨论】:

    标签: ios cocoa-touch uiview uiviewcontroller uibarbuttonitem


    【解决方案1】:

    在您的UIApplication 实例上使用-beginIgnoringInteractionEvents-endIgnoringInteractionEvents。这正是像 UINavigationController 这样的类在动画推送到新视图控制器时所做的。要获取 UIApplication 的特定实例,请在 UIApplication 类上使用 +sharedApplication 方法。考虑这个例子。

    [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
    [[UIApplication sharedApplication] endIgnoringInteractionEvents];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-29
      相关资源
      最近更新 更多