2009-09-22 55 views

回答

2

首先,您可以用來控制應用程序中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