1

在此处输入图像描述

代码片段

   NSMutableArray *samplepdf = [[NSMutableArray alloc]initWithObjects:@"sam1.pdf",@"sam2.pdf",@"sam3.pdf",@"sam4.pdf", nil];


  1)  QLPreviewController *previewController = [[QLPreviewController alloc] init];
    previewController.dataSource = self;
    previewController.currentPreviewItemIndex = [indexPath row];
    [self presentModalViewController:previewController animated:YES];


2) 


- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)previewController
{

    return [samplepdf count];

}


// returns the item that the preview controller should preview
- (id)previewController:(QLPreviewController *)previewController previewItemAtIndex:(NSInteger)index
{   

    NSString *documentsDirectoryPath = [[NSBundle mainBundle]resourcePath]; 

    NSString *dataPath =[documentsDirectoryPath stringByAppendingPathComponent:[samplepdf objectAtIndex:index]];


    NSURL *url = [NSURL fileURLWithPath:dataPath isDirectory:YES];  
    return url; 
}

此代码在 iOS5 中完美运行,但是当我在 ios6 中运行时,一些空间是可见的。

我该如何解决这个问题?

提前致谢 :)

4

1 回答 1

0

对 presentModalViewController:animated: 的调用在 iOS6 中已弃用。您可能希望在调用 presentViewController:animated: 之前指定模态转换样式和模态演示样式。你可以尝试这样的事情:

  [previewController setModalPresentationStyle:UIModalPresentationFullScreen];
  [previewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];

  [self presentViewController:previewController animated:YES completion:nil];
于 2013-02-11T05:18:06.273 回答