Open Browser Map Using Buttonpressed In iPhone

In this application we will see how to browser or map is launch when we pressed the button from the main window.

Step 1: Create a Window-base application using template . Name of the project “OpenBrowser”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the OpenBrowserAppDelegate class for you. Expand Resources and notice the template generated a separate nib MainWindow.xib for the OpenBrowser.

Step 4: Now we’ll add UIViewController class to the project. Choose New file -> Select cocoa touch classes group and then select UIViewController . Give the name of the class OpenBrowserViewController. Create one more UIViewController class file give the name MainViewController. Create another UIView class and corresponding .xib file, give the name MainView.

Step 5:In the OpenBrowserAppDelegate.h file we define the OpenBrowserViewController class and create the instance of the class. Make the following changes in the file:

 

 

 

Step 7: In the OpenBrowserViewController.h file, we define the MainViewController class , UIButton for displaying the button.So make the following changes:

 

 

 

Step 8: Double click the MainWindow.xib file and open it to the Interface Builder. First drag the ViewController from the library and place it to the Main window. Select the View Controller and bring up Identity Inspector, change the class name into the OpenBrowserViewController. Now open the OpenBrowserViewController, drag the Round Rect from the library and place it to the view window select the Round Rect and bring up Attributes Inspector  then change the type of the button into info Light. Select the OpenBrowserViewController icon from the main window and bring up Connection Inspector drag from infoButton to the Light info button. Now save the nib file, close it and go back to the Xcode.

Step 9: In the OpenBrowserViewController.m file make the following changes:

 

 

 

Step 10: Now open the MainViewController.h file and add the IBAction for open the Maps or Browser. Make the following changes:

 

 

 

Step 11: Double click the MainView.xib file and open it to the Interface Builder. Select the view icon from the main window and bring up Identity Inspector change the class name into the MainView, now select the File’s Owner icon from the main window and bring up Identity Inspector and change the class name into the MainViewController. Now drag two Round Rect from the library and place it to the view window double click the Round Rects and change the names into OpenBrowser and OpenMap. Select the OpenBrowser button and bring up connection inspector drag from the TouchUpInside to the File’s Owner icon and select openBrowser action. Now select the OpenMap button from the view window and bring up connection inspector next drag TouchUpInSide to the File’s Owner icon and select openMap action. Save you nib, close it and go back to the Xcode.

Step 12: In the MainViewController.m file make the following changes:

 

 

 

Step 13: Now compile and run the application.

You can downloaded SourceCode from here OpenBrowser 2

Leave a Comment: