【发布时间】:2020-02-03 16:11:11
【问题描述】:
我需要使用 Objective-c 显示来自非 UIView 类的警报。
下面是代码:
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@“Sample” message message:@“hello message” preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {}]];
[[[UIApplication sharedApplication] delegate].window.rootViewController presentViewController:alertVC animated:YES completion:nil];
上面的这个不再起作用了,我无法在objective-c中找到相同代码的任何其他替代方案。 我遇到了这个链接How to resolve: 'keyWindow' was deprecated in iOS 13.0,但解决方案是在 Swift 中,而不是在 Objective-c 中。
谢谢
【问题讨论】:
-
在目标 c 中尝试相同的单词
标签: objective-c ios13 uialertcontroller uiwindow