iOS:使PDF视图的大小与设备宽度高度相同

时间:2014-05-17 09:33:09

标签: ios pdf orientation uipageviewcontroller autoresizingmask

背景中有灰色,我无法制作PDF的完整尺寸。有没有办法全屏显示PDF?我已经检测到方向并相应地制作了pdf大小。

编辑:

NSString *path = [[NSBundle mainBundle] pathForResource:@"PDF2" ofType:@"pdf"];
NSURL *pdfUrl = [NSURL fileURLWithPath:path];
PDFDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef)pdfUrl);
totalPages = (int)CGPDFDocumentGetNumberOfPages(PDFDocument);
//modelArray holds the page numbers
modelArray = [[NSMutableArray alloc] init];

for (int index = 1; index <= totalPages; index++) {

    [modelArray addObject:[NSString stringWithFormat:@"%i", index]];

}

thePageViewController = [[UIPageViewController alloc]
                         initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
                           navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
                                         options:nil];

thePageViewController.delegate = self;
thePageViewController.dataSource = self;

thePageViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

contentViewController = [[ContentViewController alloc] initWithPDF:PDFDocument];
contentViewController.page = [modelArray objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:contentViewController];
[thePageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

[self addChildViewController:thePageViewController];
[self.view addSubview:thePageViewController.view];
thePageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

[thePageViewController didMoveToParentViewController:self];

self.view.backgroundColor = [UIColor underPageBackgroundColor];

enter image description here

enter image description here

0 个答案:

没有答案