【发布时间】:2015-10-08 11:15:20
【问题描述】:
我已经使用
展示了视图控制器[self presentViewController:viewController animated:YES completion:nil];
在呈现的视图控制器中,我试图呈现 UIAlertcontroller,它没有呈现也在 iOS 8.4.1 的控制台中显示警告
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertAction *extend_action = nil;
UIAlertAction *ok_action = nil;
UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Call will begin"
message:msg_str
preferredStyle:UIAlertControllerStyleAlert];
extend_action = [UIAlertAction actionWithTitle:@"Extend Time?"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
// Method.
}];
ok_action = [UIAlertAction actionWithTitle:@"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
}];
[controller addAction:extend_action];
[controller addAction:ok_action];
[self presentViewController:controller animated:YES completion:nil];
});
尝试在其视图不在窗口层次结构中呈现 UIAlertController! 我得到了警告。
【问题讨论】:
-
如消息所述,您试图将警报呈现到不可见的视图中。
-
您是如何创建警报的?你能显示你的
UIAlertController代码和你添加到UIAlertController的UIAlertActions 吗? -
@DogCoffee,那么我需要在呈现警报控制器时进行修改。
-
需要更多代码,为什么不升级到 iOS 9 并使用 Swift??
-
看起来不错,我唯一能想到的是,当 VC A 在屏幕上时,这是在 VC B 中调用的(例如)——你从哪里调用这个方法?在模态解雇或其他什么??
标签: ios objective-c uiviewcontroller uialertcontroller