2011-10-15 74 views
0

我有一个基于视图的应用程序,最后只有一个WebView ...带有一些图标的Tabbar。 所以我需要添加一个小图标返回到localHTML文件home.html。IBAction打开本地HTML文件

也许有人可以给我一些信息如何处理它,而无需改变视图到一个新的?

下面是我的其他IBActions看起来像

- (IBAction)news_button:(id)sender; { 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.google.com"]]; 
} 

其他选项可以打开一个网站,但不是在Safari ......像它的时刻。

感谢您的分享! :)

回答

0

随着上面的行,你现在在Safari中打开它。

你可以得到本地文件路径,如果它在主束目录同

NSString *filePath = [[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"home.html"] retain]; 

那么为什么不使用

[yourWebView loadRequest:[NSURLRequest initWithURL:[NSUrl initWithString:filePath]]]; 
+0

应该这样: [NSURL initWithString:文件路径] 是这个:(大写'rl'和类方法): [NSURL URLWithString:filePath]? –