问题
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