2011-10-21 2 views
1

この問題はナットを運転しています。すべてのUIWebView:サイズを表示するフレームに合わせて、そのフレーム内でUISplitViewControllerのスクロールを許可します

CGSize boundsSize = self.view.bounds.size; 
self.webView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, boundsSize.width, boundsSize.height)] autorelease]; 
self.webView.delegate = self; 
self.webView.opaque = NO; 
self.webView.backgroundColor = [UIColor redColor]; 
self.webView.allowsInlineMediaPlayback = YES; 
self.webView.dataDetectorTypes = UIDataDetectorTypeAddress | UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber; 
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin; 
[self.view addSubview:webView]; 

まず、フレームサイズが時にビューをフィットさせるためのIアカウント行う方法:

は私がUISplitViewControllerの右側の完全なビューを埋める作るしようとしているのUIWebViewを持っています私はオリエンテーションを知らないのですか?適切なサイズに自動サイズ変更できますか?

次に、WebViewにHTMLを読み込むと、フレームサイズを同じにしたい(UIScrollViewのように)が、その新しいコンテンツをそのフレームでスクロールできるようにします。一部のコンテンツはずっと長く、一部はそうではありません。だから、私はフレームを調整しようとしましたが、これはちょうど私のコンテンツサイズよりも私のフレームを大きくします。

- (void)webViewDidFinishLoad:(UIWebView *)aWebView { 

    // Calculate the size of our webview 
    CGRect frame = aWebView.frame; 
    frame.size.height = 1; 
    aWebView.frame = frame; 
    CGSize fittingSize = [aWebView sizeThatFits:CGSizeZero]; 
    frame.size = fittingSize; 
    aWebView.frame = frame; 

}//end 

これはできませんか? WebViewをUIScrollViewの中に入れ、webViewにロードするたびにcontentSizeを新しいコンテンツの高さに設定する必要がありますか?

答えて

-4

私は手動で負荷に私のフレームを調整しなければならなかったようだ:

// Orientation 
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; 

    // Create frame 
    CGRect frame; 
    if (UIInterfaceOrientationIsLandscape(orientation)) { 
     frame = CGRectMake(0, 0, 748, 1024); 
    } else { 
     frame = CGRectMake(0, 0, 768, 1022); 
    }//end 
0

自動サイズ調整のマスクを見てください。私はそれがあなたがこの仕事をするために必要なすべてだと思う。

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW6

+0

申し訳ありませんが、私はすでにそれを持っています、ここに投稿することを忘れてしまった。私の例に追加されました。 –

+0

iOS 5.httpでこの問題が発生している可能性があります://stackoverflow.com/questions/7767302/how-to-inform-the-parent-viewcontroller-about-thechanged-screen-orientation-in – logancautrell

2

私はそれはあなたがこの作品を作るために必要なすべてのだと思います。

[articleWebView sizeThatFits:CGSizeZero];

関連する問題