Home > iOS, iPhone, iPhone Programing Tutorial, xCode > In built web browser for native iPhone app

In built web browser for native iPhone app

Hello Friends,

Today I am going to provide you with steps on how to create in built web browser for iPhone apps. Easy 6 step procedure.

Step 1: Create new project from xCode File->New Project. Choose “View-based Application”¬†and give a name as “InAppBrowser”.

New Project


Step 2: Now xCode will create all minimum required files for you. Open “InAppBrowserViewController.xib” file from left panel and add one textfield to enter url. Add one button next to added text field and give it title as “Go”. So we will code on tap of this button to load url in browser. Now add UIWebView to this view as shown in below image.

Browser ViewStep 3: Now open “InAppBrowserViewController.h” and add below code to it.

@interface InAppBrowserViewController : UIViewController
IBOutlet UITextField *txtUrl;
IBOutlet UIWebView *webView;
- (IBAction)onGo:(id)sender;

Step 4: Now assign this newly created outlets to relevant textfield and webview and action to UIButton(Go) Touch Up Inside Event in Interface builder.

Step 5: Now add method implementation of onGo in “InAppBrowserViewController.m” file. Use below code for that.

- (IBAction)onGo:(id)sender
NSURL *url = [NSURL URLWithString:txtUrl.text];
[webView loadRequest:[NSURLRequest requestWithURL:url]];
[txtUrl resignFirstResponder];

Step 6: Now build and run your app. Enter http://google.com in url textfield and tap on “Go” button. This will open Google in webview. See below screenshot for final output.

That’s it! We are done now. If you want to download code then click here.

  1. No comments yet.
  1. No trackbacks yet.