我有一个ipad uiwebview,它必须显示一些rtfd.zip文件。我试着这样做:
-(void) viewWillAppear:(BOOL)animated { [self loadFile:string]; } - (void)loadFile:(NSString*)file { NSString* resourcePath = [[NSBundle mainBundle] bundlePath]; NSString* sourceFilePath = [resourcePath stringByAppendingPathComponent:file]; NSURL* url = [NSURL fileURLWithPath:sourceFilePath isDirectory:NO]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; [webview loadRequest:request]; [resourcePath release]; }
但我只得到一张空白页。这些插座确实连接正确-uiwebview可以加载谷歌主页。
我做错什么了? 事先谢谢!
试着用这个,我用这个得到了输出,
- (void)loadFile:(NSString*)file { UIWebView *webview=[[UIWebView alloc] init]; NSString *FullstrURL=[[NSBundle mainBundle] pathForResource:file ofType:@"html" ]; NSLog(@"HTML String = %@",FullstrURL); [webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:FullstrURL]]]; }