Transition to UITabBarController

不打扰是莪最后的温柔 提交于 2019-12-11 14:32:25

问题


I need help with bug fix. I'm use segue to transit between ViewControllers.

I have UITabBarController with one UIViewController. When I click on button in my vc I move to second vc. My second vc doesn't have TabBar. (use segue). In my second vc I have button and UIAlertController. When I click on button or alert I must transit to first vc with TabBar, but my TabBar doesn't displayed. How to fix this ? I don't need to use 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


回答1:


If you are presenting the second ViewController modally add this to your UIAlertController action:

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



回答2:


Add below code to your FirstViewController from where you are moving to NextController via segue.

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

    UIViewController* sourceViewController = unwindSegue.sourceViewController;

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

And go to storyboard, right click and hold and drag from Button on NextController to Exit responder.

And you method name appears, connect to that.

Please refer this answer : What are Unwind segues for and how do you use them?



来源:https://stackoverflow.com/questions/56313087/transition-to-uitabbarcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!