【发布时间】:2016-05-11 13:48:46
【问题描述】:
我想用UIAlertControllerStyleAlert 风格呈现UIAlertController,同时用UIAlertControllerStyleActionSheet 风格解散UIAlertController。换句话说,我想在点击操作表中的选项后显示警报视图。但是没有出现alertview,只有日志中出现这条消息:
尝试加载视图控制器的视图 不允许解除分配,可能会导致未定义的行为
这是我的代码:
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];
actionsheet 工作正常,alertview 不工作。操作表来自UITableViewController。非常感谢您的每一个帮助,在此先感谢
【问题讨论】:
标签: ios objective-c uialertview uiactionsheet uialertcontroller