每当我翻页时,在pageviewcontroller中使用Pagecurleffect它会重叠工具栏。
这是我的代码
- (void)viewDidLoad {
[super viewDidLoad];
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];
}
在viewdidload中使用此代码的内容视图控制器
- (void)viewDidLoad
{
[super viewDidLoad];
// Create our PDFScrollView and add it to the view controller.
CGPDFPageRef PDFPage = CGPDFDocumentGetPage(thePDF, [_page intValue]);
pdfScrollView = [[PDFScrollView alloc] initWithFrame:CGRectMake(0, 46, self.view.bounds.size.width, 915)];
[pdfScrollView setPDFPage:PDFPage];
[self.view addSubview:pdfScrollView];
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
pdfScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 965, self.view.bounds.size.width, 40)];
_toolbar.barStyle = UIBarStyleBlackOpaque;
[self.view addSubview:_toolbar];
}
在翻页时与工具栏重叠时效果不佳。我怎么能解决这个问题。
我想要第二张图片
导航栏下方的页面与导航栏不重叠。 感谢
答案 0 :(得分:3)
您正在每个页面中添加一个工具栏,它位于页面内。
您必须在第一个代码块上创建工具栏,并在末尾添加[self.view bringSubviewToTop:_toolbar];