3

ログインフォームでユーザーが認証されたときに、UIWebViewにモーダルでWebページをロードするiPadアプリを開発しています。これはうまく機能しますが、デバイスを横向きモードに回転させると、Webビューは画面の75%しかカバーしません。

問題を示すスクリーンショット

これが私のログインビューコントローラーからのコードです:

    // Load storyboard for easy instatiation of the login view controller
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];
    WebViewController *webController =
    (WebViewController *)[storyboard instantiateViewControllerWithIdentifier:@"WebView"];

    // Present the embedded browser in fullscreen.
    [webController setModalPresentationStyle:UIModalPresentationFullScreen];
    [self presentViewController:webController animated:YES completion: nil];
4

3 に答える 3

4

制約または自動サイズ変更マスクを使用していますか?そうでない場合は、それらを使用して、Webビューがビューのフレーム全体をカバーしていることを確認することをお勧めします。

于 2012-11-28T19:22:50.963 に答える
1

あなたがしなければならないのはあなたの方法でUIWebView横向きのフレームを定義することです。 -shouldAutorotateToInterfaceOrientationWebViewController

こんな感じで、

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

 if(toInterfaceOrientation == UIInterfaceOrientationPortrait)
 {
     webView.frame = CGRectMake (0, 0 768, 1024);
 }
 else 
 {
     webView.frame = CGRectMake (0, 0 1024, 768);
 }
 return YES;
}
于 2012-11-28T18:10:23.897 に答える
0
  1. webViewデリゲートを使用する2.このメソッドを含める
    • (void)webViewDidFinishLoad:(UIWebView *)webView {[self.webView setFrame:CGRectMake(0、0、self.view.frame.size.width、self.view.frame.size.height)]; }
      }
  2. これも含める

    • (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {[self.webView setFrame:CGRectMake(0、0、self.view.frame.size.width、self.view.frame.size.height)]; }
于 2015-09-15T08:05:19.297 に答える