我使用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;
}
希望这有助于一些之一。
包含表视图的视图控制器被压入常规的UINavigationControler,它是我给出的代码示例中最顶层的视图控制器。我会认为WebController引起的调用也会被推送。我是否需要专门给WebController或TTNavigator引用正在使用的UINavigationControllr? – lukestringer90 2012-01-07 20:36:22
不,这通常不会是这样,但可能值得一试。在'TTNavigator'上使用'setRootViewController:'。 – tonklon 2012-01-07 22:36:19
那里没有喜乐。 – lukestringer90 2012-01-08 01:33:58