2012-01-07 126 views
0

我使用Three20框架中的TTTableView類來創建具有樣式內容的表格視圖單元格,其中包括帶有URL的HTML。細胞看起來和工作幾乎沒有問題。 URL被拾取,然後點擊其中一個適當的委託方法。但是,URL在TTWebController中打開,TTWebController沒有後退箭頭來彈出導航堆棧的視圖。TTNavigator沒有推入導航堆棧

繼承人我的代碼:

TTTableStyledTextItem *messageItem = [TTTableStyledTextItem itemWithText:[TTStyledText textFromXHTML:message lineBreaks:YES URLs:YES]]; 
messageItem.delegate = self; 

TTListDataSource *dataSource = [[TTListDataSource alloc] init]; 
[dataSource.items addObject:messageItem]; 

TTNavigator* navigator = [TTNavigator navigator]; 
navigator.delegate = self; 
navigator.window = [UIApplication sharedApplication].delegate.window; 

TTURLMap* map = navigator.URLMap; 
[map from:@"*" toViewController:[TTWebController class]]; 


self.tableView.dataSource = dataSource; 
self.tableView.delegate = self; 

的網址會強調了在細胞和攻一個火災這種方法:

- (BOOL)navigator: (TTBaseNavigator *)navigator shouldOpenURL:(NSURL *) URL { 
return YES; 

}

似乎是TTWebController並沒有被壓入導航堆棧,它只是「顯示」而沒有後退箭頭。有什麼想法嗎?

更新我的解決方案 周圍打後多一些,我認爲這個問題是是,我試圖使用Three20網址導航方法,而在同一時間使用普通的iOS的UINavigationController推新視圖控制器。顯示TTWebcontroller的位置是Three20導航堆棧中的第一個視圖控制器,因此它是根視圖控制器,因此不具有任何「返回」到先前視圖的概念。

這裏是我的解決辦法:

- (BOOL)navigator: (TTBaseNavigator *)navigator shouldOpenURL:(NSURL *) URL { 
    // setup a webcontroller with the URL and push it 
    TTWebController *webController = [[TTWebController alloc] init]; 
    [webController openURL:URL]; 
    [self.navigationController pushViewController:webController animated:YES]; 
    [webController release]; 

    // dont navigate with TTBaseNavigator 
    // this does not use the regular UINavigation stack and 
    // ... the new view becomes rootview and has no back button 
    return NO; 
} 

希望這有助於一些之一。

回答

0

這可能發生取決於你如何呈現包含tableView的viewController。它viewController推到一個UINavigationController或調用每個URL(在這種情況下,Three20會自動爲你創建一個navigationController)。

您需要確保帶有WebController的navigationController可以被推送。

+0

包含表視圖的視圖控制器被壓入常規的UINavigationControler,它是我給出的代碼示例中最頂層的視圖控制器。我會認爲WebController引起的調用也會被推送。我是否需要專門給WebController或TTNavigator引用正在使用的UINavigationControllr? – lukestringer90 2012-01-07 20:36:22

+0

不,這通常不會是這樣,但可能值得一試。在'TTNavigator'上使用'setRootViewController:'。 – tonklon 2012-01-07 22:36:19

+0

那裏沒有喜樂。 – lukestringer90 2012-01-08 01:33:58