【发布时间】:2019-09-28 16:37:11
【问题描述】:
我有以下功能,它会弹出一个 UIAlert,允许用户更新他们的触觉反馈设置:
- (void)requestHapticSetting{
UIWindow *alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
alertWindow.rootViewController = [[UIViewController alloc] init];
alertWindow.windowLevel = UIWindowLevelAlert + 1;
[alertWindow makeKeyAndVisible];
if(isHapticOn){
hapticMessage = @"Haptic feedback is currently\nturned ON.\nPlease update preference.";
}
else {
hapticMessage = @"Haptic feedback is currently\nturned OFF.\nPlease update preference.";
}
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Haptic Setting"
message:hapticMessage
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* onAction = [UIAlertAction actionWithTitle:@"TURN ON" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self saveHapticSettingOn];
}];
UIAlertAction* offAction = [UIAlertAction actionWithTitle:@"TURN OFF" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self saveHapticSettingOff];
}];
[alert addAction:offAction];
[alert addAction:onAction];
[alertWindow.rootViewController presentViewController:alert animated:YES completion:nil];
}
我已经用了几年了,效果很好。
但是,自从更新到 iOS 13 并更新到最新的 Xcode 后,我的警报在关闭前弹出了不到一秒钟。
发生了哪些变化?提前致谢。
【问题讨论】:
-
这本质上是 stackoverflow.com/questions/58131996/… 的副本,但这是在 Swift 中,当您支持场景时,它的答案在 iOS 13 下将无法正常工作。
-
您是在 iOS 13 下的应用中使用场景,还是选择完全退出场景(您不应该这样做)?
-
@rmaddy 我不完全确定。我使用生成 Xcode 项目的游戏引擎。不幸的是,在过去添加这个一直有效到现在。谢谢。
标签: objective-c uialertview uialertcontroller ios13