gpt4 book ai didi

ios - 如何从 UIAlertView 按钮解除 segues

转载 作者:行者123 更新时间:2023-11-29 12:37:45 26 4
gpt4 key购买 nike

我有 3 个 View Controller 。第一个是从我的 Root View Controller 模态呈现的。

它们位于使用 push 从第一到第三的导航堆栈中。

我的最终 View Controller (第三个)有一个 UIAlertView,按下 ok 后,我想放松到第一个 View Controller 。

但是,我所读到的任何关于这种展开的内容都建议使用 -(IBAction),这是通过 Storyboard按钮激活的系统。

我如何从第三个 View Controller 退回到第一个 View Controller ?我用过

[self performSegueWithIdentifier:segueString sender:self];

但它在尝试再次导航时使应用程序崩溃

最佳答案

所以你需要使用如下的 UIAlertView Delegate 方法,

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//Using buttonIndex you could find whether OK or CANCEL is pressed and perform your popToRootViewController call.
//Below on OK press then moving to root VC
if (buttonIndex==0)
{
//OK is pressed...
[self.navigationController popToRootViewControllerAnimated:YES];
}
else{
//CANCEL is pressed...
}
}

希望这对你有帮助。

关于ios - 如何从 UIAlertView 按钮解除 segues,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25806040/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com