我想要UIAlertController
和UIAlertControllerStyleAlert
样式,而使用UIAlertControllerStyleActionSheet
样式解除UIAlertController
样式。换句话说,我想在从动作表中点击一个选项后显示一个alertview。但是,没有alertview被呈现,则仅显示此消息日志中:在另一个UIAlertController原因中存在UIAlertController试图在释放视图控制器时加载视图控制器的视图是不允许的
尝试而它是 解除分配不允许加载视图控制器的视图,并且可以导致未定义的行为
这里我的代码:
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"MyApp" message:@"Info" preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
// Cancel button tappped.
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Credits" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Credits"
message:@"Here some text in the alertview..."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:@"Close"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//Handel your yes please button action here
}];
[alert addAction:yesButton];
[self dismissViewControllerAnimated:YES completion:^{
// try to present the alertview
[self presentViewController:alert animated:YES completion:nil];
}];
}]];
// Present action sheet.
[self presentViewController:actionSheet animated:YES completion:nil];
该操作表正在工作,而不是alertview。操作单从UITableViewController
提供。非常感谢每一个帮助,在此先感谢
我犯了多么愚蠢的错误......谢谢!还要感谢@Mike Taverna – Kurtis92