ちびり文 このページをアンテナに追加 RSSフィード

2008-10-28

UIWebViewを表示するためのシンプルなUIViewController

MyWebViewController.h

#import <UIKit/UIKit.h>

@interface MyWebViewController : UIViewController <UIWebViewDelegate> {
	UIWebView *webView;
}

@end

MyWebViewController.m

#import "MyWebViewController.h"

@implementation MyWebViewController

// Implement loadView to create a view hierarchy programmatically.
- (void)loadView {
	self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
	webView = [[UIWebView alloc] initWithFrame:[self.view frame]];
	[webView setDelegate:self];
	[self.view addSubview: webView];
}

// Implement viewDidLoad to do additional setup after loading the view.
- (void)viewDidLoad {
	[super viewDidLoad];
	[webView loadRequest:[NSURLRequest requestWithURL:
		[NSURL URLWithString:@"http://www.google.co.jp"]]];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIDeviceOrientationLandscapeRight);
}

- (void)didReceiveMemoryWarning {
	[super didReceiveMemoryWarning]; 
}

- (void)dealloc {
	[super dealloc];
	[webView release];
}

@end

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証

トラックバック - http://d.hatena.ne.jp/ppmp451z/20081028/1225209322
Connection: close