gpt4 book ai didi

iphone - 显示 UIAlertView 时可以收到消息吗

转载 作者:行者123 更新时间:2023-12-03 20:21:06 26 4
gpt4 key购买 nike

我想在系统显示 UIAlertView 时收到消息,以便我可以暂停游戏。

有人知道怎么解决吗?

UIAlertView不是由我自己控制的。

最佳答案

系统警报通常显示在其自己的UIWindow中。为 UIWindowDidBecomeVisibleNotificationUIWindowDidBecomeHiddenNotification 通知安装处理程序,以分别跟踪 UIWindow 何时变得可见和隐藏:

 [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(aWindowBecameVisible:)
name:UIWindowDidBecomeVisibleNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(aWindowBecameHidden:)
name:UIWindowDidBecomeHiddenNotification
object:nil];

在处理程序中,从通知的 object 属性中获取更改状态的 UIWindow:

- (void)aWindowBecameVisible:(NSNotification *)notification
{
UIWindow *theWindow = [notification object];
NSLog(@"Window just shown: %@", theWindow);
}

- (void)aWindowBecameHidden:(NSNotification *)notification
{
UIWindow *theWindow = [notification object];
NSLog(@"Window just hidden: %@", theWindow);
}

最后,检查 theWindow 是否包含 UIAlertView 类型的 subview 。

关于iphone - 显示 UIAlertView 时可以收到消息吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6607170/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com