IOS UIWebView定位问题

Zee*_*eem 2 cocoa-touch objective-c uiwebview ios6

我是iOS新手,只需创建一个小型本机应用程序,加载一个URL,该URL托管在IIS上并在Jquery移动设备上制作.问题是当我改变方向时,它是从右侧剪切,而同样的东西在所有Android设备上正常工作.请帮帮我

这是我的代码

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIWebView *webView=[[UIWebView alloc]initWithFrame:CGRectMake(0.0, 0.0,768,1024)];


    NSString *httpSource=@"http://www.mydomain.com";
    NSURL *fullUrl=[NSURL URLWithString:httpSource];
    NSURLRequest *httpRequest=[NSURLRequest requestWithURL:fullUrl];
    webView.delegate=self;
    [webView loadRequest:httpRequest];
    [self.view addSubview:webView];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
Run Code Online (Sandbox Code Playgroud)

cha*_*ndu 6

您必须为webView设置自动调整大小,或者您可以使用Autolayout.

- (void)viewDidLoad {

       [super viewDidLoad];

       //Here you use the frame of Total View, irrespective of device type
       UIWebView *webView=[[UIWebView alloc]initWithFrame:self.view.bounds];

       //Autoresizemask
       webView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
       NSString *httpSource=@"http://www.mydomain.com";
       NSURL *fullUrl=[NSURL URLWithString:httpSource];
       NSURLRequest *httpRequest=[NSURLRequest requestWithURL:fullUrl];
       webView.delegate=self;
       [webView loadRequest:httpRequest];
       [self.view addSubview:webView];
     }
Run Code Online (Sandbox Code Playgroud)