0
在我的应用程序中,我有一个UIWebView加载不同的rtf文件。我使用这个函数来加载这些文件:UIWebview不显示我想要它显示的内容
- (void)loadFile:(NSString*)file
{
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
NSString* sourceFilePath = [resourcePath stringByAppendingPathComponent:file];
NSURL* url = [NSURL fileURLWithPath:sourceFilePath isDirectory:NO];
NSURLRequest* request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
}
UIWebView什么都不显示。当我进入调试器时,文件字符串值是我需要的,但是resourcePath和sourceFilePath值是“nil”。我究竟做错了什么?
在此先感谢!
sourceFilePath值为“无”,无论如何 – Knodel 2010-06-05 12:42:18
@Knodel:?只有当该文件不存在时,这将返回'nil'。确保存在'file'。 – kennytm 2010-06-05 12:48:03
文件绝对在我的项目中。也许问题是我使用NSString * Path = [[NSBundle mainBundle] bundlePath]; \t NSString * DataPath = [Path stringByAppendingPathComponent:@“Data.plist”]; - 在我的appdelegate.m? – Knodel 2010-06-05 12:59:22