-1

これをviewDidLoadで書いていますが、

// Programmatically creating uiwebview. 
UIWebView *webVPrg = [[UIWebView alloc] initWithFrame:self.view.frame];
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSMutableURLRequest *urlReq = [[NSMutableURLRequest alloc] initWithURL:url];
[self.view addSubview:webVPrg];
[webVPrg loadRequest:urlReq];

ここで作成された Web ビューは、縦向きと横向きに正しく配置されませんが、Web ビューがInterface Builderで作成された場合は正常に機能します。

( initWithFrame:self.view.frameに何か問題があるかどうかはわかりません)

何が問題なのですか?

4

1 に答える 1

1

次を設定する必要がありautoresizingMaskます。

webVPrg.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

スーパービューに応じてビューのサイズを自動的に調整します。あなたもあなたと同じことをする必要があるでしょうself.view

于 2013-02-08T09:20:34.833 に答える