iOS Development - An introduction to Storyboard Part 2

Dec 11, 2017 iOS 中文版

In the previous post iOS Development - An introduction to Storyboard Part 1, I believe you’ve built a basic understanding of Storyboard. In this post, I’m going to show you how to set initial view controller and how to specify a Class for your view controller step by step.



Set initial view controller of Storyboard

Remember what is an entry point? When you open Storyboard, you should be able to see an arrow pointing to a scene, which means this is the entry point of your application. It’s draggable and removable. Yes, you can delete that arrow, but the system won’t work correctly once you delete it. So, how do we reset it if we accidentally delete it? First, select a scene (View Controller) and go to Attributes Inspector, and check Is initial View Controller like this:

ios storyboard



Specify a Class for your view controller

In the previous post, I’ve mentioned we can control a view controller through codes, but you have to specify a Class for it in the first place. Let me show you how to do that. Now, create a Tabbed application and add a new Swift file, then select Cocoa Touch Class template like this: ios storyboard After that, enter the name of your view controller, and then set Subclass of as UIViewController like this: ios storyboard Now, we’ve successfully created a new Swift file, but the system still doesn’t know you want to use this file for your view controller. Therefore, you have to specify it manually. In Storyboard, select a view controller you want and go to Identity Inspector, then set Class as the name of the newly added Swift file (should be one of select options). Like this:

ios storyboard

After setting up, each line of code in that Swift file is going to affect your view controller. Now, you are able to customize it. In the following posts, I will introduce more features of Storyboard.


You might also like:




If you have any suggestions, questions or even find some typos, feel free to contact me. Thank you! :)

zeckli.devforgalaxy@gmail.com   © 2015-2019 zeckli, thanks to Jekyll and GitHub.