How to Use Navigation in iPhone and iPad
In this article I will explain the process of moving from one page to another using a navigation controller in iPhone or iPad.
In this article we create an Empty view application. In this we create a view using the uiviewcontroller class. To create the uiviewcontroller class we do the following.
Select the appdelegate.m class and right-click on it ->choose new file ->select objective C class ->click on next ->by default the class name is ViewController. When you choose subclass UIViewController, change the name to whatever you want; if you want to use xib then you mark on it -> click on next -> select the location where you import the view controller class in the project.
To navigate one view to another here I use two the UIViewController class. First class name first view controller and Second class name second view controller. In this article I use one button and one label in the First view and a single label is used in the second view using xib. When we click on the first button "click!" it navigates from one view to another.
Open XCode by double-clickiing on it.
Create a New XCode Project by clicking on it.
Now select an Empty View Application and click on Next.
Now Give your Product a Name. Here I use Nevigation and Company Identifier Mcn Solutions and Click on Next.
Select the location where you want to save your project then click on Create.
Now you can see in the XCode Window two Objective C classes that were generated by XCode; they are:
Now we add two UIViewControllers, as in the following.
Select the appdelegate.m class and right-click on it; see:
Choose New File..
Select Subclass of UIViewController from drop down list and give the class name. Here I use the class name First view controller and click on the checkbox with xib user interface. For using a label and button from xib.
Click on next.
Now click on create, to import a class to the project; see:
Repeat the same steps to add a second view controller class.
After that we add code for navigation and linking.
Now select which Platform you want to see the output for.
Output 1 for iPhone:
Output 2 for iPhone:
Output 1 for iPad:
Output 2 for iPad: