[英]Webview works for iphone but not for ipad
below code is working on Iphone, I am having an issue with the webview loading on ipad, it hits the didFailwith error, (iPad is connected) any help appreciated?下面的代码在 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];
}
You can check like this..你可以这样检查..
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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.