开发者

UIWebview isn't displaying content I want it to display

开发者 https://www.devze.com 2023-01-02 22:12 出处:网络
In my app I have a UIWebView which loads different rtf files. I use this function to load these files:

In my app I have a UIWebView which loads different rtf files. I use this function to load these files:

- (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];
开发者_开发知识库}

The UIWebView displays nothing. When I enter the debugger, the file string value is which I need, but resourcePath and sourceFilePath values are "nil". What am I doing wrong?

Thanks in advance!


Try using -pathForResource:ofType: instead.

NSString* sourceFilePath = [[NSBundle mainBundle] pathForResource:file ofType:nil];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号