how to connect two viewcontrollers to same navigationcontroller in storyboard iphone

若如初见. 提交于 2019-12-11 09:25:06

问题


I am doing an application where i can check for a condition in Appdelegate class as follows:-

if([array count] == 0) {one viewController} else{another viewController}

How will i do this in storyboard like i'm asking the connection so that the corresponding viewcontrollers are displayed.

I'm new to iphone development.Thanks in advance.


回答1:


The way to do this is:

  1. Create a regular UIViewController: this will be your root view controller.
  2. Create the 2 other UIViewControllers.
  3. Create 2 segues from the root view controller in step #1 to the 2 in step #2.
  4. Put your condition check in the viewDidAppear: launch the appropriate segue based on your condition.
  5. Embed the root view controller in a navigation controller (go to the Editor menu in Xcode and then select Embed In).


来源:https://stackoverflow.com/questions/22446046/how-to-connect-two-viewcontrollers-to-same-navigationcontroller-in-storyboard-ip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!