代码来打开iphone webView中的.docx
我是iPhone新手,我试图在UIwebView中打开.docx文件,我写了下面的代码
NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"Arabic literature" ofType:@"docx"]; NSURL *url = [NSURL fileURLWithPath:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; NSData *data = [NSData dataWithContentsOfFile:urlAddress]; //[_webView loadRequest:requestObj]; [_webView loadData:data MIMEType:@"application/vnd.ms-word" textEncodingName:@"UTF-8" baseURL:nil];
但它给了我以下例外:
DiskImageCache: Could not resolve the absolute path of the old directory. Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
考虑到我在支持文件中复制了“Arabic literature.docx”文件。 我怎么能解决这个exception?
好吧,你为什么不使用这样的东西:
NSURLRequest *request = [NSURLRequest requestWithURL:url]; [_webView loadRequest:request];
抱歉的意见不起作用,所以不得不作为答案。
- 如何解决CBPeripheralManager的传输队列已满?
- 如何确保API请求来自我们的移动(iOS / Android)应用程序?
- 如何在使用Xamarin.UITest访问iOS上的照片所需的权限对话框中点击确定按钮?
- Time Profiler仪器中的“Self”和“#Self”是什么意思?
- 纯Swift类符合协议与静态方法 – 问题与上传
- 这个证书在ios钥匙串中有一个无效的发行者
- Xamarin.iOS本地化NSLocationWhenInUseUsageDescription
- 滚动时,两个组件的UIPickerView崩溃
- performBlock:和performBlockAndWait之间的行为差异:?