Tutorial – Navigation Controller in iOS

0
1655

In our blog today you will learn to use the navigation controller in iOS. We will show you the simple steps to follow to get the example up and running

1. Open the new Project Template and select Single View Application.

Navi-iOS-pic1

2. Name the project as “Navigation” and check “Use StoryBoards”

Navi-iOS-pic2

3. After saving the project you will get the following screen

Navi-iOS-pic3

4. Click on the main story board file and delete it. We just need the storyboard option there.

5. Now drag out a navigation controller as shown

Navi-iOS-pic4

6. Navigation controller comes with Table view. We do not need a table view so we will delete that view.

7. Now we are left with the navigation controller as shown

Navi-iOS-pic5

8. Navigation Controller maintains other views as arrays of views.

9. Next we will set up a root view controller. Drag a view controller and add it to the navigation controller.

10. We will now wire root view controller of the navigation controller to the new view controller as shown below

Navi-iOS-pic6

Navi-iOS-pic7

11. Now set the title bar of the root view as ” First view”

12. If we now run the application we will see this view showing “First View”

Navi-iOS-pic8

13. Now we will implement navigation. We will drag out one more view controller and will add to our screen.

14. We will further add a button to the old view so that pressing it takes us to the next view.

Navi-iOS-pic9

15. Now we will click on the button and drag it to the new view as shown and select push segue.

Navi-iOS-pic10

16. It makes the new view member of the navigation controller. Now put the name as “Second View” in the title bar.

Now if we execute the application we will be able to move from the first view to the second and vice versa.

To see this tutorial you can also visit of yourtube channel. The Link to video is as follows

We hope you enjoyed the blog.