假设您已经注册了您的导航器TTWebController这样:
TTNavigator* navigator = [TTNavigator navigator];
TTURLMap* map = navigator.URLMap;
[map from:@"*" toViewController:[TTWebController class]];
你可以简单地打开本地HTML文件的方式:
NSString *creditsPath = [[NSBundle mainBundle] pathForResource:@"credits" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:creditsPath];
TTOpenURL([url description]);
然后,你只需要添加TTTableLinkedItem或subcl驴(几乎所有的TT *小区内有)到你的数据源与本地文件URL这样的:
NSString *creditsPath = [[NSBundle mainBundle] pathForResource:@"credits" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:creditsPath];
TTTableTextItem *item = [TTTableTextItem itemWithText:@"foobar" URL:[url description]];
简单多了什么我以前写...
ENDOFEDIT
忘记whats下,除非你有兴趣在别人的解决方案...(更复杂...或不,看最后一个)
基本上这里是你如何在UIWebView OAD内容:
NSString *creditsPath = [[NSBundle mainBundle] pathForResource:@"credits" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:creditsPath];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[webView loadRequest:urlRequest];
的three20TTWebController可以在查询请求:
- (id)initWithNavigatorURL:(NSURL*)URL query:(NSDictionary*)query {
if (self = [self initWithNibName:nil bundle:nil]) {
NSURLRequest* request = [query objectForKey:@"request"];
if (nil != request) {
[self openRequest:request];
} else {
[self openURL:URL];
}
}
return self;
}
所以要打开一个TTWebController本地HTML文件,你可以这样做:
NSString *creditsPath = [[NSBundle mainBundle] pathForResource:@"credits" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:creditsPath];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[[TTNavigator navigator] openURLAction:
[[[TTURLAction actionWithURLPath:@"url://to/your/ttwebcontroller"]
applyQuery:[NSDictionary dictionaryWithObject:ulrRequest
forKey:@"request"]]
applyAnimated:YES]];
现在最后一部分,从TTTableViewController触发这个... 你有y我们的ViewController实施:
- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath {
// there you retrieve a *TTTableItem* corresponding to your row
// and call previous snippet from URL...
// TTTableItem class has userInfo property you could use:
TTTableItem *item = (TTTableItem *)object;
NSString *htmlFile = item.userInfo.
[self openLocalHtmlFile:htmlFile];
}
希望帮助! 没有测试过任何东西,不应该编译或任何,但这是一个解决方案。
这是一个使用基本的three20 + iOS功能的解决方案。你也可以写一个TTCustomWebController从TTWebController继承,将采取类似的网址是@"myapp://openLocalHtml?file=credits"并不难做到...
...这里是一个草案:
@interface TTCustomWebController : TTWebController {}
@end
@implementation TTCustomWebController
- (id)initWithFile:(NSString *)name {
self = [super init];
if (self) {
NSString *filePath = [[NSBundle mainBundle] pathForResource:name ofType:@"html"];
NSURL *URL = [NSURL fileURLWithPath:filePath];
[self openURL:URL];
}
return self;
}
@end
然后,你可以简单地使用TTTableLinkedItem在你的数据源中指向这些@"myapp://openLocalHtml?file=credits" ...
祝你好运!:)