2011-04-28 62 views
3

我創建一個UIWebView並設置自動旋轉這樣的:如何使用正確的縮放比例顯示UIWebView的景觀

- (void)loadView 
{ 
    self.view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)] autorelease]; 

    UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; 
    webview.delegate = self; 
    webview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_darkgreen_320x312.png"]]; 
    webview.dataDetectorTypes = UIDataDetectorTypeLink; 
    webview.multipleTouchEnabled = YES; 
    webview.scalesPageToFit = YES; 
    webview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 
    [webview loadHTMLString:@"<meta name=\"viewport\" content=\"width=320\">content ..." baseURL:nil]; 
    [self.view addSubview:webview]; 

} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

它完美,當我在景觀旋轉它,而不進行縮放。它將在兩次旋轉中全屏顯示。

的問題是,如果我縮小或一點點放大在縱向模式下,然後在橫向旋轉,網頁流量仍與縱向模式相同的尺寸放大,它有像圖片>http://cl.ly/1o3c4712053C3T2C2H2z

黑色空間

它的橫向寬度是正確的,480px(你可以看到它的滾動條位於屏幕的最右側)。我不明白爲什麼webview不顯示全屏。

我做錯了什麼? 有什麼辦法解決這個問題嗎? 請幫忙。

在此先感謝。

+0

你是否設法解決這個問題? – Vin 2011-06-27 11:51:24

+0

我發現其他應用程序也有這個問題(如Facebook)。我認爲這是來自蘋果的錯誤...? – Dolly 2011-07-15 19:51:44

+1

有同樣的問題 - 問題在這個線程中解決: http://stackoverflow.com/questions/2890673/iphone-uiwebview-width-does-not-fit-after-zooming-operation-uiinterfaceorientat – 2011-09-02 19:31:14

回答

相關問題