gpt4 book ai didi

ios - 进入后台状态时关闭 UIAlertViews

转载 作者:IT王子 更新时间:2023-10-29 07:46:54 25 4
gpt4 key购买 nike

Apple 建议在 iOS 4 中进入后台状态时关闭任何 UIAlertViews/UIActionSheets。这是为了避免用户稍后重新启动应用程序时出现任何混淆。我想知道如何优雅地立即关闭所有 UIAlertView,而无需在每次设置时都保留对它的引用...

有什么想法吗?

最佳答案

我的做法是向 UIAlertview 添加一个类别,添加以下函数:

- (void) hide {
[self dismissWithClickedButtonIndex:0 animated:YES];
}

并订阅 UIApplicationWillResignActiveNotification :

[[NSNotificationCenter defaultCenter] addObserver:alertView selector:@selector(hide) name:@"UIApplicationWillResignActiveNotification" object:nil];

关于ios - 进入后台状态时关闭 UIAlertViews,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3105974/

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