【问题标题】:Transition to UITabBarController过渡到 UITabBarController
【发布时间】:2019-05-26 11:28:36
【问题描述】:

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

我有一个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

【问题讨论】:

  • 你能把你的按钮动作代码放在你要转移到第二个VC的地方吗?如果可能的话还有故事板 UI 截图?
  • @VRAwesome 按钮我不使用代码。 segue -> 显示

标签: swift segue uistoryboardsegue


【解决方案1】:

如果您正在展示第二个 ViewController,请将其添加到您的 UIAlertController 操作中:

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

【讨论】:

    【解决方案2】:

    将以下代码添加到您的FirstViewController,从您要通过segue移动到NextController

    - (IBAction)unwindToFirst:(UIStoryboardSegue *)unwindSegue {
    
        UIViewController* sourceViewController = unwindSegue.sourceViewController;
    
        if ([sourceViewController isKindOfClass:[SecondViewController class]]) {
             NSLog(@"Coming from SECOND!");
        } else {
             NSLog(@"Handle Error");
        }
    }
    

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-28
      • 2015-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-15
      • 2015-06-22
      • 2014-12-18
      相关资源
      最近更新 更多