我是一名 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/