开发者

Problem with TTWebController… alternative view controller template for UIWebView?

开发者 https://www.devze.com 2022-12-26 19:38 出处:网络
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:

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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消