gpt4 book ai didi

iphone - Webview 适用于 iPhone,但不适用于 iPad

转载 作者:行者123 更新时间:2023-11-29 04:42:50 25 4
gpt4 key购买 nike

下面的代码在 Iphone 上运行,我在 ipad 上加载 webview 时遇到问题,它遇到了 didFailwith 错误,(iPad 已连接)有任何帮助吗?

 - (void)viewDidAppear:(BOOL)animated
{
NSURL *url;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
url = [NSURL URLWithString:@"http://www.google.com"];
}else{
url = [NSURL URLWithString:@"http://www.google.com"];
}
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webSurfForecast loadRequest:req];
[super viewDidAppear:YES];
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}

最佳答案

你可以这样检查..

  BOOL iPad = NO;
#ifdef UI_USER_INTERFACE_IDIOM
iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#endif
if (iPad) {
// iPad specific code here
} else {
// iPhone/iPod specific code here
}

关于iphone - Webview 适用于 iPhone,但不适用于 iPad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10104156/

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