我的应用程序在视图中的开始,所有的观点有4个按钮 ,让你跳转到A,B,C的一个TabBar,所以d如何以编程方式添加多个导航控制器?
我目前拥有的是这样的情景:
如果您导航到A,B,C,D中的任意一个,则您将回到堆栈底部 ,并且顶部的所有人都将被清除。
,但我需要它来表现这样的形象,例如这些导航发生
1: A>1
2: B>3>7
3: C>2>5>6>8>7
4: D>9>1
现在,当我从1移动到B,我回到7,为B
顶部问题:我假设我需要多个导航控制器,对不对?我也把这个didFinishLaunchingWithOptions
功能放在appDelegate
,如何以编程的方式做多个导航控制器?在A,B推送或加载视图控制器之间使用什么?
////////// NC
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainView = storyboard.instantiateViewControllerWithIdentifier("selectLocation") as! selectLocation // 1 Home
let searchView = storyboard.instantiateViewControllerWithIdentifier("2") as! Search // 1 Home
let friendsView = storyboard.instantiateViewControllerWithIdentifier("3") as! Friends // 1 Home
let meView = storyboard.instantiateViewControllerWithIdentifier("4") as! Me // 1 Home
var nav1 = UINavigationController()
nav1.viewControllers = [mainView]
nav1.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
var nav2 = UINavigationController()
nav2.viewControllers = [searchView]
nav2.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
var nav3 = UINavigationController()
nav3.viewControllers = [friendsView]
nav3.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
var nav4 = UINavigationController()
nav4.viewControllers = [meView]
nav4.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
UINavigationBar.appearance().barTintColor = UIColor(red: 176.0/255.0, green: 190.0/255.0, blue: 105.0/255.0, alpha: 1.0)
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UINavigationBar.appearance().barStyle = UIBarStyle.BlackTranslucent
self.window!.rootViewController = nav1
self.window?.makeKeyAndVisible()
////////// NC
注意: - 我已经解决了这个问题,如果你需要解决方案,我将准备一个示例github项目并链接到它。 – DeyaEldeen
你有没有可能获得GitHub示例的机会? – SQLiteNoob