Display Map Wed Using ButtonPress In iPad

In this application you can see how to display WebPage, Map using ButtonPress in the iPad. This is the very simple example. Let see how it will be worked.

Step 1: Create a application using Window base template. Give the application name “WebMapDisplay”.

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 “WebMapDisplay”.

Step 4: We need to add two UIViewController class to the project. Choose New file -> Select cocoa touch classes group and then select UIViewController . Give the class name “WebMapDisplayViewC0ntroller”, create another ViewController class and corresponding .xib file, give the class name “MainViewController”. Now add UIViewclass, Choose New file-> Select cocoa touch class -> select Objective C class -> select UIView from the Subclass of. Also create corresponding .xib file . Give the class name “MainView”.

Step 5: Open the AppDelegate.h file and add WebMapDisplayViewController class, and create an instance of the class. Make the following changes in the file.

 

 

 

Step 6: In the AppDelegate.m file make the following changes:

 

 

 

Step 7: Now open the WebMapDisplayViewController.h file, we have added MainViewController class and create an object of the class, add UIButton . So now 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 WebMapDisplayViewController. Now open the WebMapDisplayViewController, 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 WebMapDisplayViewController 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: Open the WebMapDisplayViewController.m file and make the following changes:

 

 

 

Step 10: In the MainViewController.h file we have added two method fro display map and webpage. So make the following changes:

 

 

 

Step 11:Double click the MainViewController.xib file and open it to the Interface Builder. Select the File’s Owner icon from the MainWindow and bring up Identity Inspector and change the class name into MainViewController. Next select the View icon from the mainwindow and bring up Identity Inspector and change the class name into “MainView”.Drag two Round Rect from the library and place it to the view window. Give the Round Rect name “OpenMap” and “OpenBrowser”. Connect File’s Owner icon to the MainView icon and select view. Select OpenMap from the view window and bring up Connection Inspector and drag TouchUpInside to the File’s owner icon and select ShowMap: method, do it once again for OpenBrowser and select ShowBrowser: method. Now save the .xib file, close it and go back to the Xcode.

Step 12: Open the MainViewController.m file and make the following changes in the file.

 

 

 

Step 13: Now compile and run the application in the Simulator.

You can download SourceCode from here WebMapDisplay

Leave a Comment:

1 comment
mikezang says June 3, 2010

Hi
How can I browse map on local png files? I mean I want to browse google map offline, do you have any idea?

I have the goole map in png files.

Reply
Add Your Reply