2013-08-29 56 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:];

我希望这会有所帮助。

相关问题