使用Three20导航到webview
问题描述:
如何使TTNavigator示例代码使其中一个选项卡直接进入Web视图或直接进入YouTube视频等?这里是当前的代码 http://pastie.org/626186使用Three20导航到webview
答
首先,您可以用来控制应用程序中URL分派的类是TTURLMap。您可以在TTNavigatorDemo的AppDelegate.m文件中看到它是如何设置的。
这里的诀窍是你可以在设置你的TTURLMap时使用通配符。由“*”通配符设置到控制器类,就等于告诉你TTURLMap派遣所有否则不匹配的请求到任何控制器类传递给它的一个新实例(在您的情况TTWebController)
TTURLMap* map = navigator.URLMap;
[map from:@"*" toViewController:[TTWebController class]];
[map from:@"tt://someController" toViewController:[SomeController class]];
...
if (![navigator restoreViewControllers]) {
[navigator openURL:@"tt://someController" animated:NO];
}
我刚才检查TTNavigatorDemo,它看起来像这其实已经建立:
// Any URL that doesn't match will fall back on this one, and open in the web browser
[map from:@"*" toViewController:[TTWebController class]];
因此,在你的要点,你应该能够访问与已经在网络视图控制器任意URL,添加一行到您的数据像这样的源代码。攻击这应该推动一个新的谷歌TTWebController:
[TTTableTextItem itemWithText:@"Google" URL:@"http://google.com"],
进一步阅读:NavigatorDemo做了一些非常酷的东西。 Three20 Google Group的某人发布了their notes when they were unpacking everything that's going on in the TTURLMap setup。