过渡到UITabBarController

时间:2019-05-26 11:28:36

标签: swift segue uistoryboardsegue

我需要有关错误修复的帮助。我使用segue在ViewController之间进行转换。

我有一个UITabBarController和一个UIViewController。当我单击vc中的按钮时,我将移至第二个vc。我的第二个vc没有TabBar。 (使用segue)。在第二个vc中,我有按钮和UIAlertController。当我单击按钮或警报时,我必须使用TabBar转换到第一个vc,但不会显示我的TabBar。如何解决呢?我don't需要使用NavigationController

let alert = UIAlertController(title: "Поздравляю", message: "Тренировка окончена", preferredStyle: UIAlertController.Style.alert)
        alert.addAction(UIAlertAction(title: "Click", style: UIAlertAction.Style.default, handler: { action in self.performSegue(withIdentifier: "backSegue", sender: self) }))
        self.present(alert, animated: true, completion: nil)

StoryBoard

2 个答案:

答案 0 :(得分:0)

如果要显示第二个ViewController,请将其模态添加到UIAlertController操作中:

self.dismiss(animated: true, completion: nil)

答案 1 :(得分:0)

将以下代码从FirstViewController移至NextController的位置添加到segue

- (IBAction)unwindToFirst:(UIStoryboardSegue *)unwindSegue {

    UIViewController* sourceViewController = unwindSegue.sourceViewController;

    if ([sourceViewController isKindOfClass:[SecondViewController class]]) {
         NSLog(@"Coming from SECOND!");
    } else {
         NSLog(@"Handle Error");
    }
}

然后转到情节提要,右键单击并按住,然后从Button上的NextController拖动到退出响应程序。

segue_1

出现方法名称,然后连接到该名称。

segue_2

请参考以下答案:What are Unwind segues for and how do you use them?