2014-08-28 89 views
-6

我有表视图包含文件列表,它将单元格单击时的网络视图,正确的文件路径从表格视图传递到网络视图,但网页视图加载空白页面。下面是我用UIWebview加载空白页

- (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); 

} 

需要帮助解决这个问题的代码。

回答

0

我解决了这个问题,错误在该线下方

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

低于线

destViewController.path = [inboxPath stringByAppendingPathComponent:[dirFiles objectAtIndex:indexPath.row]]; 
取代了它