ios - 如何从 LaunchScreen 过渡到 Swift 中的主页?

标签 ios swift uiviewcontroller

我是 Swift 编程的新手。我想知道如何从头开始创建一个应用程序(从一开始就没有启动屏幕,没有第一页,也没有 Storyboard)——我删除了我所有的 ViewControllers 和它们相关的 Storyboard以及启动屏幕。我设法使初始屏幕正常工作,但无法将其转换到第一页(目前也存在)。

我做过的事情: 创建了新的 Storyboard,其中包含主页的 View Controller 和扩展 UIViewController 的关联 swift 文件。也将两者联系起来。

但我无法让启动屏幕转换到主页。对此的任何帮助将不胜感激。我也尝试与其他 Swift 项目进行比较,但我不知道如何进行。

编辑:

import UIKit

class MyViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

这是我的主页 View Controller 。我的 Storyboard非常基础,里面没有 ui 元素,只有一个 View Controller 。 @nobre 已经回答了这个问题。

最佳答案

您必须将目标的主界面 指向您的 Storyboard。 enter image description here

在代码中,您必须在 AppDelegate 中创建一个 UIWindow 实例,并将框架设置为 NSScreen.mainScreen.bounds,创建以编程方式将您的 View Controller 设置为窗口的 rootViewController,然后在窗口上调用 makeKeyAndVisible

关于ios - 如何从 LaunchScreen 过渡到 Swift 中的主页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37258449/

相关文章:

iphone - NSCoding持久化UIImage

ios - 如何整合多个框架调用到openURL :(NSURL *)url

iphone - 如何停止多个 UIButton 按下?

ios - 当textField有输入文本时如何更新约束

ios - 是什么导致了 <Error> : CGContextSetBaseCTM: invalid context 0x0 when implementing loadView?

ios - .animationImages API Cocos 2D?

swift - 如何在 TextView 中键入 '@' 后检测字符串

swift - coreML 验证输入失败

ios - 为什么我应该避免在整个应用程序中只使用一个 UIViewController

cocoa - UINavigationController 内的 UITabBar 使用 Storyboard