iphoneobjective-cuiwebviewthree20ttnavigator

Problem with TTWebController… alternative view controller template for UIWebView?


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?


Solution

  • 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