PHP Web Dev 101
PHP Web Dev 101

Reputation: 555

Make UIwebView 100% screen size

How can I make this code for a UIwebView 100% height and width?

  UIWebView *webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 1024,768)];
    NSString *url=@"http://www.google.com";
    NSURL *nsurl=[NSURL URLWithString:url];
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
    [webview loadRequest:nsrequest];
    [self.view addSubview:webview];

Upvotes: 0

Views: 447

Answers (1)

Fred Faust
Fred Faust

Reputation: 6790

When you make your frame use your current view's self.frame.size.width & self.view.frame.size.height instead of 1024 & 768.

UIWebView *webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)];

Upvotes: 1

Related Questions