0

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

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Rozgen
  • 47
  • 7

2 Answers2

0

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

self.dismiss(animated: true, completion: nil)
Ludyem
  • 1,709
  • 1
  • 18
  • 33
0

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.

segue_1

And you method name appears, connect to that.

segue_2

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

VRAwesome
  • 4,721
  • 5
  • 27
  • 52