我一直堅持在這幾天。我正在測試這個使用iOS模擬器。我有一個假設加載URL的webView。它似乎嘗試加載URL,因爲當我加載雅虎URL時,頂部的Yahoo圖標/橫幅會顯示,但實際的URL內容不會加載,它只是一個空白的空白區域。如果我加載另一個網址,例如「http://www.google.com」,它上面沒有任何橫幅,它只會是空白的webView。如果我更改代碼以在模擬器中使用Safari應用程序打開相同的URL,那麼一切正常。請幫忙!!Xcode的UIWebView沒有顯示URL的內容,空白的webview,沒有錯誤
WebViewController.h:
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (strong, nonatomic) NSString *urlBusinessLink;
@end
WebViewController.m:
- (void)viewDidLoad {
[super viewDidLoad];
@try {
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", self.urlBusinessLink]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest: request];
}
@catch (NSException *exception) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"Website is unavailable." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertView show];
}
}
當我通過運行代碼,沒有任何錯誤。我輸入的異常處理也沒有收到任何東西。它看起來像是在加載url的時候被凍結,或者它不斷刷新,所以沒有內容真正顯示。
嗨,你使用哪個雅虎URL? – mityaika07 2014-11-03 23:02:31
https://local.yahoo.com/info-21329298-akiko-s-sushi-bar-san-francisco – yuanz90 2014-11-03 23:10:41
對於一瞬間我可以看到從雅虎加載的圖片,但我說話像毫秒。然後它消失,只有雅虎旗幟顯示。 – yuanz90 2014-11-03 23:14:25