ios - 快速更改 AppDelegate 中的初始 View Controller

标签 ios iphone swift viewcontroller appdelegate

我创建了第一个 Swift 应用程序,并在 AppDelegate 函数中设置了一个 viewController:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

 var tableVC:FriendsTableViewController = FriendsTableViewController(className: "Friend")
    tableVC.title = "FriendFamz"

    UINavigationBar.appearance().tintColor = UIColor(red: 0.05, green: 0.47, blue: 0.91, alpha: 1.0)
    UINavigationBar.appearance().barTintColor = UIColor(red: 0.05, green: 0.47, blue: 0.91, alpha: 1.0)
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
    UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent


    var navigationVC:UINavigationController = UINavigationController(rootViewController: tableVC)

    let frame = UIScreen.mainScreen().bounds
    window = UIWindow(frame: frame)

    window!.rootViewController = navigationVC
    window!.makeKeyAndVisible()

现在我想更改应用程序的第一个 View :我想创建一个登录 View (带有登录ViewController),但我不知道如何创建这个 View ,然后它会调用我的 FriendTableViewController ...

有谁能帮忙吗?太好了,我已经被屏蔽了好几个小时了…… 非常感谢

最佳答案

最简单的方法是转到您的设置并将初始 View 设置为第一个 View 。

如果您使用 Storyboard,则只需按住 Control 并单击一个 View 即可切换到另一个 View 。为 Segue 命名。

在您的登录中,如果成功,请使用标识符执行segue。有数百个关于此的教程。

关于ios - 快速更改 AppDelegate 中的初始 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31466246/

相关文章:

xcode - 闭包不可构造

ios - 如果我误删除了MainStoryboard_iPad,如何制作通用应用程序

ios - 无法将带有框架的应用程序上传到 iTunes Connect

swift - 检测 UITabBar 项目何时选择 swift

ios - 在 CAGradientLayer 上方显示 SCNScene

ios - 更新播放器远程控制事件的目标操作方法(MPRemoteCommand)

ios - 是否可以将 C 结构打包到 Cocoa 中的 NSKeyedArchiver 中?

ios - 在 iOS 中一天中的特定时间调用方法

iphone - 使用 Core Data 设计聊天应用程序

iPhone 如何保存 View 状态