How to add item for tab bar controller in storyboard of Xcode
Storyboard is good for decoupling the UI from your business logic, but sometimes it could be challenge if you are a newbie.
We will start from the very start.
Create a storyboard
CMD+N
to create a new file: User interface - storyboard- Single click the newly created storyboard to open it as the
interface builder
mode.
Create a Tab Bar Controller
- Open
Object library
in theUtilities
panel, the shortcut isCTRL+ALT+CMD+3
- Drag
Tab Bar Controller
into the storyboard. Now we have a tab bar controller along with 2 sub tab items.
Add a new Tab Bar Item
- Let’s add the 3rd tab bar item.
- Drag
View controller
into the storyboard. - Drag
Tab Bar Item
into the newly created view controller, it will sit at the same level of theView
.
Add the segue
- From the
Tab Bar Controller Scene
, holdCTRL
and drag a line from it to the new view controller. - From the pop-up, select
Relationship Segue - view controllers
End
Enjoy :)
Thanks for reading!
Follow me (albertgao) on twitter, if you want to hear more about my interesting ideas.