views:

287

answers:

1

I have a UIWebView with content populated from a Last.fm API call.

This content contains links, many of which are handled by parsing info from the URL in:

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

…and passing that info on to appropraite view controllers.

When I cannot handle a URL I would like to push a new view controller on the stack and load the webpage into a UIWebView there.

The TTWebController in Three20 looks very promising since it has also implemented a navigation toolbar, loading indicators etc.

Somewhat naively perhaps I thought I would be able to use this controller to display web content in my app, without implementing Three20 throughout the app. I followed the instructions on github to add Three20 to my project and added the following code to deal with URLs in shouldStartLoadWithRequest:

TTWebController* browser = [[TTWebController alloc]init];
[browser openURL:@"http://three20.info"]; //initially test with this URL
[self.navigationController pushViewController:browser animated:YES];

This crashes my app however with the following notice:

*** -[TTNavigator setParentViewController:]: unrecognized selector sent to instance 0x3d5db70

What else do I need to do to implement the TTWebController in my app?

Or do you know of an alternative view controller template that I can use instead of the Three20 implementation?

A: 

This works for me:

NSURL *myURL = [[NSURL alloc] initWithString:@"http://www.google.com"];
MyWebView *webBrowser = [[MyWebView alloc] initWithNavigatorURL:myURL query:nil];
[myURL release];
[self.navigationController pushViewController:webBrowser animated:YES];

where MyWebView is just a simple subclass of TTWebController

hyperphonic
I'll have to try that asap, thanks for the suggestion
prendio2
I wonder now glancing at the code, if the error was a result of sending a NSString to openURL instead of a NSURL. Will find out as soon as I can.
prendio2
the error was indeed caused by sending a NSString as opposed to a NSURL to the openURL: method… live and learn… thanks
prendio2