20分 html文件是,Three20显示本地html文件

假设您已经注册了您的导航器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" ...

祝你好运!:)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值