2010-02-06 91 views

回答

3

NSURLConnection應該給你一些NSData。然後,您可以使用-loadData:MIMEType:textEncodingName:baseURL:將這些數據加載到Web視圖中。

(可以使用-loadRequest:如果你不需要加載之前操作數據。)

1
responseData = [NSURLConnection sendSynchronousRequest: request 
            returningResponse:&response 
               error: &error]; 
NSString *htmlBody = [[NSString alloc] initWithData:responseData 
              encoding:NSUTF8StringEncoding]; 

[webview loadHTMLString:htmlBody baseURL:nil]; 
1

你去那裏與GCD::)

NSURL *urlObj = [NSURL URLWithString:url]; 

    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); 

    dispatch_async(queue, ^{ 

     NSURLRequest *request = [NSURLRequest requestWithURL:urlObj]; 

     [webViewObj loadRequest:request]; 

     dispatch_sync(dispatch_get_main_queue(), ^{ 

      [webViewObj release]; 

     }); 

    }); 

希望它能幫助。