gpt4 book ai didi

objective-c - IOS UIWebView 方向问题

转载 作者:行者123 更新时间:2023-12-04 03:08:38 24 4
gpt4 key购买 nike

我是 iOS 的新手,只需要制作一个小型 native 应用程序来加载 URL,该应用程序托管在 IIS 上并在 Jquery 移动设备上制作。问题是当我改变它从右侧剪裁的方向时,同样的事情在所有安卓设备上都能正常工作。请帮帮我

这是我的代码

#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

最佳答案

您必须为您的 webView 设置自动调整大小掩码,或者您可以使用自动布局。

- (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];
}

关于objective-c - IOS UIWebView 方向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21179364/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com