Translate

Monday, April 2, 2012

WebView Application in iPhone

In this application we will see how to WebView display in the view window . So let see how it will worked.
Step 1: Open the Xcode, Create a new project using View Base application. Give the application “MapViewiPhone”.
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 ViewController class for you. Expand Resources and notice the template generated a separate nib, MapViewiPhoneViewController.xib for the MapViewiPhone application.
Step 4: We need to add MapKit.framework in the Frameworks folder.
Step 5: Open the MapViewiPhoneViewController.h file and make the following changes:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface MapViewiPhoneViewController : UIViewController {
 
    IBOutlet MKMapView *map;
   
}
@property(nonatomic, retain) IBOutlet MKMapView *map; @end
Step 6: Double click the MapViewiPhoneViewController.xib file and open it to the Interface Builder. First drag the mapview from the library and place it to the View window. Connect File’s Owner icon to the view window and select map. Now save the .xib file, close it , and go back to the Xcode.
Step 7: Open the MapViewiPhoneViewController.m file and make the following changes:
#import "MapViewiPhoneViewController.h"
@implementation MapViewiPhoneViewController @synthesize map;
- (void)dealloc
{
    [super dealloc];
}
- (void)didReceiveMemoryWarning
{

    [super didReceiveMemoryWarning];
   
}
#pragma mark – View lifecycle
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
   
        map.mapType = MKMapTypeSatellite;
        map.mapType=MKMapTypeStandard;
       
}
- (void)viewDidUnload
{
    [super viewDidUnload];
   
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
Step 8: Now compile and run the application on the Simulator.



You can Download SourceCode from here MapViewiPhone

No comments:

Post a Comment