【问题标题】:Changing Storyboard in swift快速更改情节提要
【发布时间】:2016-03-18 23:22:43
【问题描述】:

我正在尝试从 Main.storyboard 切换到 Main2.storyboard。 Main.storyboard 连接到 ViewController.swift 并且 Main2.storyboard 连接到 Main2.swift

在 ViewController.swift 我有一个按钮可以切换到 Main2.stoaryboard

@IBAction func btnSwitchStoryboard(sender: AnyObject) {
        let viewController = UIStoryboard(name: "Main2", bundle: nil).instantiateViewControllerWithIdentifier("Main2")

        self.presentViewController(viewController, animated: true, completion: nil)
    }

问题是:当我按下按钮时,Main2.storyboard 从按钮升起并在一秒钟后下降,我又回到 Main.storyboard。

怎么可能留在Main2.storyboard?

我正在 iOS 9.2 / xCode 7.2.1 / Swift 上开发

【问题讨论】:

  • 然后倒下了?你在某处叫解雇吗?
  • 在其他一些按钮上,我必须延迟一条应该关闭的警报消息,但我认为更改情节提要self.dismissViewControllerAnimated(true, completion: nil) 不是问题 - 但这条线在按钮操作函数内跨度>
  • 两个问题 1. 为什么你使用 2 个 Storyboard 时 1 就足够了? 2. 你有一些关闭你的 Viewcontroller 的代码吗?
  • 我认为你应该更多地学习 UIStoryBoard。您不能更改目标 StoryBoard,而是可以从不同的 StoryBoard 中选择 UIViewController。
  • @Larme - 我在 Main2.swift 中有一个 dismissViewControllerAnimated 导致问题

标签: ios xcode swift


【解决方案1】:

我的解决方案:我曾经解雇 self.dismissViewControllerAnimated 而不是 alert.dismissViewControllerAnimated 以解雇 let alert

【讨论】:

    猜你喜欢
    • 2015-04-26
    • 1970-01-01
    • 2019-10-15
    • 2015-01-02
    • 2018-09-29
    • 2018-12-05
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多