过渡到 UITabBarController [英] Transition to UITabBarController

查看:29
本文介绍了过渡到 UITabBarController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关错误修复的帮助.我使用 segue 在 ViewControllers 之间传输.

我有 UITabBarController 和一个 UIViewController.当我单击 vc 中的按钮时,我会移动到第二个 vc.我的第二个 vc 没有 TabBar.(使用转场).在我的第二个 vc 中,我有按钮和 UIAlertController.当我单击按钮或警报时,我必须使用 TabBar 转换到第一个 vc,但我的 TabBar 没有显示.如何解决这个问题?我不需要需要使用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(警报,动画:true,完成:nil)

你的方法名称出现了,连接到那个.

请参考这个答案:什么是放松转场以及如何使用它们?

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

解决方案

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?

这篇关于过渡到 UITabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆