我想要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