【问题标题】:UIWebview loads with blank page [closed]UIWebview 加载空白页[关闭]
【发布时间】:2014-10-22 03:06:48
【问题描述】:

我的表格视图包含文档列表,该列表在单击单元格时推送到网络视图,正确的文件路径从表格视图传递到网络视图,但网络视图加载空白页面。这是我使用的代码

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"ShowPDF"]) {
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    PDFViewController *destViewController = segue.destinationViewController;
NSFileManager *filemgr = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* inboxPath = [documentsDirectory stringByAppendingPathComponent:@"Inbox"];
dirFiles = [filemgr contentsOfDirectoryAtPath:inboxPath error:nil];
destViewController.path = [documentsDirectory stringByAppendingPathComponent:[dirFiles  objectAtIndex:indexPath.row]];
}
} 

要加载 webview,我使用以下代码

- (void)viewDidLoad
{
    [super viewDidLoad];

   NSString *filePath =path;
   NSURL *url = [NSURL fileURLWithPath:filePath];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[pdfView loadRequest:request];
[pdfView setScalesPageToFit:YES];
   NSLog(@"%@", self.pdfView);

} 

需要帮助来解决此问题。

【问题讨论】:

    标签: ios objective-c uitableview uiwebview


    【解决方案1】:

    我解决了这个问题,下面这行有错误

    destViewController.path = [documentsDirectory stringByAppendingPathComponent:[dirFiles  objectAtIndex:indexPath.row]];
    

    换成下面一行

    destViewController.path = [inboxPath stringByAppendingPathComponent:[dirFiles  objectAtIndex:indexPath.row]];
    

    【讨论】:

      猜你喜欢
      • 2013-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-11
      • 1970-01-01
      • 2017-01-13
      • 1970-01-01
      • 2012-12-27
      相关资源
      最近更新 更多