Ios 通过IB和代码创建的UIWebView方向不友好
我在viewDidLoad中写这篇文章Ios 通过IB和代码创建的UIWebView方向不友好,ios,uiwebview,landscape,uiinterfaceorientation,portrait,Ios,Uiwebview,Landscape,Uiinterfaceorientation,Portrait,我在viewDidLoad中写这篇文章 // Programmatically creating uiwebview. UIWebView *webVPrg = [[UIWebView alloc] initWithFrame:self.view.frame]; NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; NSMutableURLRequest *urlReq = [[NSMutableURLRequest allo
// 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是否有问题)
可能是什么问题?您应该设置
自动重新设置任务
:
webVPrg.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
使视图根据其superview的大小自动调整其大小。你可能也需要对你的
自己做同样的事情。查看。是的,有时候仅仅问一个问题就会让你看到答案。:-)坚持我认为autoresizingmask应该应用于web视图。这完全不起作用。是的,我从我的一个源文件中复制/粘贴了,之后我立即意识到你的web视图被称为不同的…哈哈,投了反对票。还有比这更糟糕的问题。