2012-05-02 47 views
1

我有一个在两个方向w工作正常的ipad xib webview。 但如果我做放大在纵向模式下,然后在景观的WebView rotationg需要利润率从右侧webad的ipad方向问题和放大

- (void)viewDidLoad 
{ 
    NSString *[email protected]"http://www.plus.al"; 
    NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]; 
    webView.scalesPageToFit = YES; 
    [webView loadRequest:request]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation 
{ 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    { 
     if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) 
     { 

      webView.frame=CGRectMake(0, 0, 1024, 748); 

     } 
     if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) 
     { 

      webView.frame=CGRectMake(0, 0, 768, 1004); 

     } 
    else { 
     if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) 
     { 
      webView.frame=CGRectMake(0, 0, 480, 300);  
     } 
     if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) 
     { 

      webView.frame=CGRectMake(0, 0, 320, 460); 
     } 
    } 
    return YES; 
} 

请帮助me.Thanks提前。

+0

试试这个-http://stackoverflow.com/questions/2890673/iphone-uiwebview-width-does-not-fit-after-zooming-operation -uiinterfaceorienta/9035545#9035545 –

+0

@Naina Soni我尝试过,但总是会显示修正缩放两个方向。 –

回答

0

您需要使用下面的代码instead-

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 


- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration { 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    { 
     if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) 
     { 
      self.webView.frame=CGRectMake(0, 0, 1024, 748); 
     } 
     if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) 
     { 
      self.webView.frame=CGRectMake(0, 0, 768, 1004); 
     } 
     else { 
      if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) 
      { 
       self.webView.frame=CGRectMake(0, 0, 480, 300);  
      } 
      if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) 
      {     
       self.webView.frame=CGRectMake(0, 0, 320, 460); 
      } 
     } 
    } 
}