Labels

Learn the powerful enterprise adaptable database:

Getting Started With ADABAS & Natural

Tuesday, March 19, 2013

Xcode 4.6: Embedding Webpage in iOS App


This tutorial guides the reader to embed a webpage in an iOS App. The steps is adapted from http://www.appcoda.com/storyboard-tutorial-create-tab-bar-controller-and-web-view/

PRE-REQUISITE:
1) Xcode 4.6
2) Sample Webpage (Download Sample)

STEPS:

1) Create a new oroject. Choose Single View Application.

2) Give a name WebView1.


3) Click Create.


4) After project files have been created, click on the NIB file. Go to Object Panel. Find WebView object, drag to the main view.


5) Bind the WebView component to ViewController.h as an outlet. give the name webView.



6) Import Sample Html files to the project.

7) Edit viewcontroller.m as follows:


//
//  BIDViewController.m
//  WebView1
//
//  Created by NOTARAZIMAC on 3/20/13.
//  Copyright (c) 2013 Apress. All rights reserved.
//

#import "BIDViewController.h"

@interface BIDViewController ()

@end

@implementation BIDViewController

@synthesize webView;

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    
    [super viewDidLoad];
    // Add code to load web content in UIWebView
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"about.html" ofType:nil]];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end




8) run.


No comments:

Post a Comment