Ios 如何执行segue内部展开功能

Ios 如何执行segue内部展开功能,ios,segue,uistoryboard,uistoryboardsegue,Ios,Segue,Uistoryboard,Uistoryboardsegue,我有3个MVC,在这里把它们命名为A、B、C A是主MVC,按钮“菜单”通过popover segue连接到B A还通过手动显示序列连接到C B是一个popover MVC,有一个按钮“细节”连接到一个带有展开序列的按钮 C是带有详细信息的详细MVC 在A.I的展开函数中,调用performsguewithidentifier来显示C 预期的行为是 单击B中的“详细信息”按钮 B消失,A出现 C出现 但是运行我得到的应用程序 单击B中的“详细信息”按钮 B消失,A出现 C出现 消失,然

我有3个MVC,在这里把它们命名为A、B、C

A是主MVC,按钮“菜单”通过popover segue连接到B

A还通过手动显示序列连接到C

B是一个popover MVC,有一个按钮“细节”连接到一个带有展开序列的按钮

C是带有详细信息的详细MVC

在A.I的展开函数中,调用performsguewithidentifier来显示C


预期的行为是

  • 单击B中的“详细信息”按钮
  • B消失,A出现
  • C出现

但是运行我得到的应用程序

  • 单击B中的“详细信息”按钮
  • B消失,A出现
  • C出现
  • 消失,然后出现
突然出现然后消失,这不是我想要的


一些附加信息

  • 更多按钮需要Popover B
  • A嵌入到UINavigationController中。连接A->C而不是B->C,用于C顶部的后退按钮

通过使用下面的代码为它们分配故事板id,您可以轻松地在ViewController之间切换

// you need to create UIStoryboard object by giving name of your storyboard
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// here you need to create storyboard ID of perticular view where you need to navigate your app 
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"viewContIdentifire"];

// if use presentViewController this will not enables you to go back to previous view
[self presentViewController:vc animated:NO completion:nil];
                    **// OR**
// using pushViewController lets you to go back to the previous view
[self.navigationController pushViewController:vc animated:YES];
或者您仍然希望使用segue,因此必须通过实现下面的委托方法来控制它们,以便它们相应地执行

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"segueName"]) {
        // perform segue
        [self performSegueWithIdentifier:@"SegueIdentifier" sender:self]; 
    }
}

快乐编码…)

通过使用下面的代码为ViewController分配情节提要id,您可以轻松地在ViewController之间切换

// you need to create UIStoryboard object by giving name of your storyboard
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// here you need to create storyboard ID of perticular view where you need to navigate your app 
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"viewContIdentifire"];

// if use presentViewController this will not enables you to go back to previous view
[self presentViewController:vc animated:NO completion:nil];
                    **// OR**
// using pushViewController lets you to go back to the previous view
[self.navigationController pushViewController:vc animated:YES];
或者您仍然希望使用segue,因此必须通过实现下面的委托方法来控制它们,以便它们相应地执行

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"segueName"]) {
        // perform segue
        [self performSegueWithIdentifier:@"SegueIdentifier" sender:self]; 
    }
}

快乐编码…)

似乎展开函数不是调用performsguewithidentifier的正确位置

UIKit将在调用“展开”功能后弹出视图控制器

因此,推送新的视图控制器内部的“展开”功能将快速弹出

解决方案是使用标识符延迟性能

解决方案1:工作不正常

添加一个bool实例和内部viewdide,使用此实例确定是否执行segue

如果B控制器是popover,则无法工作。在B popover消失后,不会为控制器调用ViewDidDisplay

解决方案2:工作

将performsguewithidentifier推入主队列

@IBAction func unwind(segue : UIStoryboardSegue) {
    dispatch_async(dispatch_get_main_queue()) {
        self.performSegueWithIdentifier("SomeSegue", sender: self)
    }
}

似乎展开函数不是调用performsguewithidentifier的正确位置

UIKit将在调用“展开”功能后弹出视图控制器

因此,推送新的视图控制器内部的“展开”功能将快速弹出

解决方案是使用标识符延迟性能

解决方案1:工作不正常

添加一个bool实例和内部viewdide,使用此实例确定是否执行segue

如果B控制器是popover,则无法工作。在B popover消失后,不会为控制器调用ViewDidDisplay

解决方案2:工作

将performsguewithidentifier推入主队列

@IBAction func unwind(segue : UIStoryboardSegue) {
    dispatch_async(dispatch_get_main_queue()) {
        self.performSegueWithIdentifier("SomeSegue", sender: self)
    }
}

很抱歉,仍然不知道如何执行segue inside unwind函数。您可以使用序列图像板id使用上述代码部分在视图之间切换。pushViewController和PerformsgueWithIdentifier Insident unwind函数的结果相同。C控制器突然出现并消失…抱歉,仍然不知道如何执行segue inside unwind函数。您可以使用上面的代码部分使用脚本id在视图之间切换。pushViewController和PerformsgueWithIdentifier Insident unwind函数的结果相同。C控制器突然出现和消失…完美,这真的帮助我在展开功能中执行segue时更新ui完美,这真的帮助我在展开功能中执行segue时更新ui