我正在使用来自TTTableView框架的Three20类来创建带有样式内容的表视图单元格,包括带有URL的HTML。细胞看起来和工作几乎都很好。获取URL,并点击适当的委托方法之一。但是,URL是在TTWebController中打开的-- TTWebController没有反箭头来弹出导航堆栈的视图。
这是我的代码:
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;在单元格中突出显示URL,并点击一个单元格触发此方法:
- (BOOL)navigator: (TTBaseNavigator *)navigator shouldOpenURL:(NSURL *) URL {
return YES;}
TTWebController似乎没有被推到导航堆栈上,它只是“显示”而没有反箭头。有什么想法吗?
更新了我的解决方案之后,我想问题是我正在尝试使用Three20 URL导航方法来推送一个新的视图控制器,同时使用一个常规的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;
}希望这能帮上忙。
发布于 2012-01-07 20:25:34
这可能会发生,这取决于您如何显示包含viewController的tableView。viewController将其推到UINavigationController上或按url调用(在这种情况下,Three20将自动为您创建navigationController )。
您需要确保可以将navigationController和WebController一起推送到上面。
https://stackoverflow.com/questions/8771176
复制相似问题