在我的程序中uiwebview沒有加載url address.when我nslogged請求對象不是null.however當我nslog webview.request它返回null.what可能是它不是原因裝載uiwebview沒有加載網頁
- (void)viewDidLoad {
[super viewDidLoad];
self.web = [[UIWebView alloc] init];
NSString *urlAddress = @"http://www.google.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
NSLog(@"%@",requestObj);
[self.web loadRequest:requestObj];
[web setFrame:CGRectMake(0, 0, 320, 370)];
NSLog(@"%@ %@",self.web,self.web.request);
}
的NSLog的結果是
<NSURLRequest http://www.google.com>
<UIWebView: 0xbb17ff0; frame = (0 0; 320 370); layer = <CALayer: 0xbb12f20>> (null)
按照從這個網站,我改變它從IB的建議,並使它的代碼。我所做的類確認到UIWebView的delegate..both的webviewdidstart和webview完成被稱爲這些是來自這些方法的nslog輸出
webviewdidstart
webView-----><NSMutableURLRequest >
webView-----><NSMutableURLRequest http://www.google.com>
的WebView去把
webView-finished----><NSMutableURLRequest http://www.google.com>
webView-finished----><NSMutableURLRequest http://www.google.com>
仍然沒有被調用,我認爲這兩種方法的調用兩次
您的UIWebview是通過IB設置的嗎?如果不是,請首先將webview作爲子視圖添加到您的視圖中。將UIWebviewdelegate添加到您的頭文件並在您的實現文件中設置webViewDidStartLoad:委託。登錄方法檢查您的網頁是否正在加載 –
我正在通過IB設置webview ... – sujith1406