2013-08-29 58 views
0

嘿傢伙我有一個簡單的html NSString,它在瀏覽器上正常工作,但不會在iPhone上加載。我正在使用一個簡單的:[self.w loadHTMLString:errorString baseURL:nil]。我錯過了什麼?簡單的html NSString有什麼問題?

NSString* errorString = [NSString stringWithFormat: 
     @"<html><body> <iframe src=\"http://64.183.101.142:81/pda.htm\"width=\"500\" height=\"500\"></iframe></body></html>"]; 
+0

HTML看起來不完整... – futureelite7

+0

@ futureelite7缺少什麼?該HTML在瀏覽器中正常工作,所以我認爲必要的部分在那裏。 –

+0

我認爲你試圖運行的URL鏈接,即「http://64.183.101.142:81/pda.htm」需要一些認證。 –

回答

0

呦需要先加載上的WebView您的請求或HTML和使用UIWebViewDelegate方法有以下協議捕獲這個請求

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
    { 

     //capture request => request 
     //From here you have the NSURLRequest object 
    //You can extract the headers of the request to NSDictionary which will contain //the   
//authentication cookie details, token, etc. using the following method of NSURLRequest 
     //- (NSDictionary *)allHTTPHeaderFields 

    } 

來源Source link

0

如果需要身份驗證,您需要根據請求的類型修改你的字符串。

如果它是一個得到它會有一個「?」在和參數是這樣的: http://xx.xx.xx.xx:81/pda.htm?user=「userX」& passwd =「something」如果它是一種post方法,您將在請求的正文中傳遞您的數據。 [NSURLRequest setHTTPBody:];

我希望這會有所幫助。

相關問題