我已经尝试了一段时间,但是我还没有弄对。
我在一个支持文件中编写了以下的init函数:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 1024,768)];
}
return self;
}
并在 ViewController.m 中跟随
- (void)viewDidLoad
{
[super viewDidLoad];
UIWebView *view = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
NSString *url=@"http://www.google.com";
NSURL *nsurl=[NSURL URLWithString:url];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[view loadRequest:nsrequest];
}
我也尝试在appDelegate的didFinishLaunchingWithOptions:
方法中创建webview,但它也没有起作用。
正确的方法是什么?