TTWebController的问题... UIWebView的替代视图控制器模板?

时间:2010-04-12 21:43:47

标签: iphone objective-c uiwebview three20 ttnavigator

我有一个UIWebView,内容来自Last.fm API调用。

此内容包含链接,其中许多链接是通过解析以下网址中的信息来处理的:

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

...并将该信息传递给appropraite视图控制器。

当我无法处理URL时,我想在堆栈上推送一个新的视图控制器,并将网页加载到那里的UIWebView中。

Three20中的TTWebController看起来非常有前景,因为它还实现了导航工具栏,加载指标等。

有点天真或许我以为我可以使用这个控制器在我的应用程序中显示Web内容,而不是在整个应用程序中实现Three20。我按照github上的说明将Three20添加到我的项目中,并添加了以下代码来处理shouldStartLoadWithRequest中的URL:

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

但这会导致我的应用崩溃,但请注意以下事项:

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

在我的应用程序中实现TTWebController还需要做些什么?

或者您知道我可以使用的替代视图控制器模板而不是Three20实现吗?

1 个答案:

答案 0 :(得分:0)

这对我有用:

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];

其中MyWebView只是TTWebController的简单子类