Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 通过IB和代码创建的UIWebView方向不友好_Ios_Uiwebview_Landscape_Uiinterfaceorientation_Portrait - Fatal编程技术网

Ios 通过IB和代码创建的UIWebView方向不友好

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

我在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是否有问题)


可能是什么问题?

您应该设置
自动重新设置任务

webVPrg.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

使视图根据其superview的大小自动调整其大小。你可能也需要对你的
自己做同样的事情。查看

是的,有时候仅仅问一个问题就会让你看到答案。:-)坚持我认为autoresizingmask应该应用于web视图。这完全不起作用。是的,我从我的一个源文件中复制/粘贴了,之后我立即意识到你的web视图被称为不同的…哈哈,投了反对票。还有比这更糟糕的问题。