忽略 AppKit 中的 UI 事件 [英] Ignoring UI Events in AppKit

查看:21
本文介绍了忽略 AppKit 中的 UI 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想忽略 iPhone 上 UIKit 中的触摸事件,我会这样做:

If I wanted to ignore a touch event in UIKit on the iPhone I would simply do:

// Begin ignoring events
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
//Do my code 
// Stop ignoring events
[[UIApplication sharedApplication] endIgnoringInteractionEvents];

这允许我的代码在忽略"调用之间进行操作,而不必担心用户交互会改变应用程序的任何状态.

This allows my code in between the "ignore" calls to operate without having to worry about user interaction changing any state of the application.

我的问题是,如果我正在编写 Mac OS X 应用程序(AppKit 与 UIKit),我该怎么做?我基本上想在某些操作期间锁定"用户(特别是,进行网络调用和快速更改状态会排队大量网络调用,这些调用会很快相互妨碍).

My question is, how can I do this if I am writing a Mac OS X app (AppKit vs. UIKit)? I basically want to "lock-out" the user during some operations (specifically, making network calls, and changing state quickly would queue up a ton of network calls that would quickly get in the way of each other).

我需要使用 AppKit 手动管理吗?IE.放个进度条,手动禁用所有UI元素?

Do I need to manage this manually with AppKit? I.e. put up a progress bar, and disable all UI Elements by hand?

推荐答案

在桌面上,您确实不想想做这样的事情.它只适用于 iPhone,因为当时用户可能不会合理地想用你的应用程序做任何其他事情.在桌面上有多个窗口等的可能性,并且任何时候您的应用程序没有响应都被视为错误.

On the desktop you really don't want to do such a thing. It only works on the iPhone because there is nothing else a user might reasonably want to do with your app at the time. On the desktop there are possibilities for multiple windows etc. and anytime your app is unresponsive is considered a bug.

所以更直接:不,没有这样的东西.您必须使用工作表/模态面板实现相同的效果,但大多数时候应该设计 UI,使其无论如何都不是问题.

So more directly: No, there is nothing like this. You have to achieve the same effect with a sheet/modal panel, but most of the time should design the UI such that it's not a problem anyhow.

这篇关于忽略 AppKit 中的 UI 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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