ios - RootView 快速导航

标签 ios swift navigation ios8

我是一名 Objectie-C 开发人员。对于 Root View 导航,我在 Objectie-c 中使用了以下代码

 FirstViewController *fvc=[[FirstViewController alloc]init];
 UINavigationController *nv=[[UINavigationController alloc]initWithRootViewController:fvc];
 self.window.rootViewController=nv;

对于我的新项目,我正在快速完成它。我只想从 AppDelegate.swift 进行 RootView 导航。

最佳答案

检查下面的代码。首先我们创建窗口。然后分配初始化 View Controller 。然后使用 rootcontroller 作为 viewcontroller 分配导航 Controller 。和 Window 的根 Controller 作为导航 Controller 。

var window: UIWindow?
var navC : UINavigationController?
var vc:ViewController?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
    // alloc init window
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

    // view controller
    self.vc = ViewController(nibName: "ViewController", bundle: nil);

    // create navigation controller with root = vc.
    self.navC = UINavigationController(rootViewController: self.vc!);
    self.navC?.navigationBar.hidden = true;

    // window's root controller as navigation controller.
    self.window?.rootViewController = self.navC
    self.window?.makeKeyAndVisible()

    return true
}

也许这对你有帮助。

关于ios - RootView 快速导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26862244/

相关文章:

swift - 链式通用类型在 swift 中推断闭包

iphone - 无法发送推文消息。 ios5出现错误

ios - 如何每次使用 AFNetworking 读取响应 header ?

ios - 在 ios 中通过 url 在应用程序中显示视频时遇到问题

button - 使用 vaadin 避免后退按钮

java - Android 物理/电容式导航按钮

PHP:使用循环获取数组的下一个/上一个元素(如果最后一个/第一个)

ios - 使用 NSFetchedResultsController 执行搜索

ios - 在 MFMessageComposeViewController 上设置 NavigationBar 背景颜色

ios - 我需要两个计时器在同一个 View Controller ios 中工作