I have 2 view controller ,and I disabled the initial view controller of first view controller ,and enabled the second view controller,but when start the project,the initial view controller is still the first view controller ,what should I do? Thanks!
You will be able to see how your Initial View Controller currently looks like on the left side of your screen. Simply drag the View Controller to the screen to create a new one; this option is located on the bottom-right side of the screen.
To change the name of the view controller follow the simple steps. Step 2: Press and hold the control key on the keyboard and press the right click of the mouse. Step 3: A drop-down menu will occur then select refactor in the dropdown. After selecting refactor another dropdown menu will occur select Rename in that.
Tap the second view controller, and select "Is initial View Controller"
in Attributes inspector
.
Alternatively you can do this with code too.
In your AppDelegate
class's didFinishLaunchingWithOptions
method you can write
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let secondVC = storyBoard.instantiateViewControllerWithIdentifier("SecondViewController") as! SecondViewController
self.window?.rootViewController = secondVC
Edit
Swift 3.0
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let secondVC = storyBoard.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
self.window?.rootViewController = secondVC
Assuming that your storyboard name is Main.Storyboard
and your SecondViewController Storyboard ID and Restoration ID is also set in Identity Inspector and use Storyboard ID is checked.
If you are starter like me ( both iOS and OSX mechine ) and you wanted to change the entry point within same storyboard, then,
-> long press on the entry point arrow. -> drag it to the view controller you wish to make the starting point, the arrow will now move to your new screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With