我有一个模态呈现的 View Controller ,我想展开它。我已将其设置为如果我按“取消”,它将执行一个 unwind segue。但是,我想使用 UIAlertView 制作一个确认按钮。如“您确定要取消吗?”。我如何使用 UIAlertView 按钮触发展开转场?
最佳答案
在您的 .h 文件中,声明 UIAlertViewDelegate
。然后在你的 .m 文件中,你可以在取消按钮操作方法中编写代码:
- (IBAction)confirmationButtonPressed:(id)sender{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Are you sure you'd like to cancel?" delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"No",nil];
[alert show];
}
然后你可以在你的 .m 文件中添加 UIAlertView Delegate 方法:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 0){
[self dismissViewControllerAnimated:YES completion:nil];
}
}
关于ios - UIAlertView 展开 Segue 处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28080315/