Three20 and Unsigned Certificates
I am re-writing my app using the Three20 library. In my app, I am opening links to various websites, some which contain websites that have unsigned certs.
In my non-three20 app, this is how I am loading such websites (using ASIHTTPRequest):
//=======================================================================================
// Once the correct URL is set, load it using ASIHTTPRequest
-(void)loadURL:(NSURL *)localURL
{
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
if(regularLoad)
{
NSURLRequest *req = [[NSURLRequest alloc] initWithURL:localURL];
[webView loadRequest:req];
regularLoad = false;
} else {
ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:localURL];
[request setValidatesSecureCertificate:NO];
[request setDelegate:self];
[request startAsynchronous];
[request release];
}
}
//=======================================================================================
// Delegate method for ASIHTTPRequest
- (void)requestFinished:(ASIHTTPRequest *)request
{
// Use when fetching text data
NSString *responseString = [request responseString];
webView.scalesPageToFit = YES;
[webView loadHTMLString:responseString baseURL:request.url];
}
The main part of that is webView's loadHTMLString method, which a Three20 TTWebController does not have.
Has anyone been able to accomplish this in开发者_如何转开发 Three20? I have scoured the net and on here, but have found no solutions.
Thanks for any help!
You can extend the TTWebController class and add the missing loadHTMLString function yourself.
@interface WebController : TTWebController
/////////////////////////////////////////////////////////////////////////////////////////////
@implementation WebController
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL {
[_webView loadHTMLString:string baseURL:baseURL;];
}
You will need to create the web controller using the init function and not call it using the TTNavigator, so you will have a reference to it
精彩评论