gpt4 book ai didi

ios - 取消 iOS 中的导航栏操作

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:08:45 25 4
gpt4 key购买 nike

我正在开发一个涉及用户填写文本字段和浏览 View 的 iOS 应用程序。目前,导航有时使用导航栏处理,有时通过按钮处理。我尝试填写一些必填字段:如果这些字段留空,则阻止应用程序取得进展。这适用于基于按钮的导航,但不适用于导航栏。我的代码如下:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"birthPopBus"]) {
currentPopoverSegue = (UIStoryboardPopoverSegue *)segue;
pvc = [segue destinationViewController];
[pvc setDelegate:self];
}
else if([[segue identifier] isEqualToString:@"SecondBusPageSegue"]) {
//This code breaks the next page

//Check fields, and create error message (code removed for readability)...

//If the fields are not filled in, display the alert with generated string.
if(!(first && last && email && phone && address && zip && ssn && birthFilled)){
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Required Fields Missing:"
message:alertMessageMutable
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];

}

//Perform the segue, should only run if all required fields are filled.
else{
[self fillBus1Dictionary];
NSLog(@"application dictionary: %@", self.application);

SecBusPage * secondBusPage = segue.destinationViewController;
secondBusPage.application = self.application;
}
}
}

错误消息会显示,但只有在 View 更改后才会显示。因此,用户进入 SecondBusPage,并收到一条提示“您没有填写字段 X、Y、Z”。这让他们很困惑。有什么想法可以防止导航栏切换 View 吗?

提前致谢!

最佳答案

您可以通过实现条件转场来轻松实现这一点,就像我在下面链接的帖子中的回答中的那样

Conditional Segue Using Storyboard

您不能从 prepareForSegue 中取消一个 segue。而不是根据条件执行 segues

关于ios - 取消 iOS 中的导航栏操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18986832/

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