How To Use UIWebView Using Utility Application In iPhone

In this application we will see how to use UIWebView using Utility Application. When user click the Dark info Button in the Web page, it will display the next screen where text will be display. This is very simple example. Let see how it will be worked.

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

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: We need to add here three UIViewController class to the project.Choose New file -> Select cocoa touch classes group and then select UIViewController subclass. Give the name “RootViewViewController”,”MainViewController” and “FlipsideViewontroller”. Now add two UIView class to the project.Choose New file -> Select cocoa touch classes group and then select UIView subclass and corresponding .xib file.Give the name “MainView” and “FlipsideView”.

Step 4: In the AppDelegate.h file, we have added “RootViewController” class

Step 5: Make the following changes in the AppDelegate.m file :

 

 

 

Step 6: In the RootViewController.h file, add MainViewController and FlipsideViewControlller class, UIButton and UINavigationBar. Define one IBAction method. So make the following changes in the file:

 

 

 

Step 7: Double click your MainWindow.xib file and open it to the Interface Builder. Drag ViewController from the library and place it to the view window. Select ViewController and bring up Identity Inspector, change the class name into RootViewController. After that, drag the view from the library and place it to the view controller and drag button from library and place it to the view window. Select the Button and bring up Attribute inspector, change the type into Dark info. Select the RootViewController icon and bring up Connection Inspector drag from the displayButton to Dark info button and drag toggleView to the Dark info button and select TouchUpInside. Now save it, close it, and go back to the Xcode.

Step 8: In the RootViewController.m file, make the following changes in the file:

 

 

 

Step 9: Open the MainViewController.h file and add UIWebView for display the webview. So make the following changes in the file:

 

 

 

Step 10: Double click the MainView.xib file and open it to the Interface Builder. Select View icon from the Main Window and bring up Identity Inspector, change the class name into MainView, and now select File’s Owner icon and bring up Identity Inspector change the class name into the MainViewController class. Drag WebView from the library and place it to the view window. Connect File’s Owner icon to the Main View icon and select view. Next connect File’s Owner icon to the WebView and select displayWeb. Now save it. close it and go back to the Xcode.

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

 

 

 

Step 12: Open the FlipsideView.xib file in the Interface Builder. Select the view icon from the main window and bring up Identity Inspector, change the class name into FlipsideView. Next select the File’s Owner icon from the library and bring up Identity Inspector, change the class name into the FlipsideViewController. Drag Label from the  library and place it to the view window. Select the label and bring up Attribute Inspector and change the text whatever you want to display. Now save it , close it , and go back to the Xcode.

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

You can downloaded SourceCode from here WebWithUtilityApplication 2

Leave a Comment:

2 comments
waleed says August 14, 2010

HI

i like this very much,

i want to ask if its possible to implement info button on MPMoviewPlayer that display UIWebView?

i have MPMovieplayer the play video from URL
i need to add info button on my video while its playing
if the the info button is clicked it will pop a transparent UIWebView on top of the video

is this can be done? i need some help please

Reply
Juan says December 10, 2010

Thank you it is great. How send information from the Utility application to UIWebView example the url http://www.google.com or hotmail.com.

Reply
Add Your Reply