0
我在Xcode中有一个基于页面的应用程序,我试图设置它,以便左侧页面和右侧页面在横向模式下具有不同的布局。UIPageViewController - 如何在横向模式下自定义左右页面?
具体来说,如果页面位于左侧,我想设置一个不同的页面bg图像,以便它看起来更像一本真正的书。
有没有一种方法可以以编程方式检测UIPageViewController在横向模式下是左侧还是右侧?你将如何去解决这个问题?
我在Xcode中有一个基于页面的应用程序,我试图设置它,以便左侧页面和右侧页面在横向模式下具有不同的布局。UIPageViewController - 如何在横向模式下自定义左右页面?
具体来说,如果页面位于左侧,我想设置一个不同的页面bg图像,以便它看起来更像一本真正的书。
有没有一种方法可以以编程方式检测UIPageViewController在横向模式下是左侧还是右侧?你将如何去解决这个问题?
如果您有背景图像的属性,你可以改变它的viewControllerAtIndex
- (YourPageContentViewController *)viewControllerAtIndex:(NSUInteger)index {
// Return the data view controller for the given index.
if (([self.modelArray count] == 0) || (index >= [self.modelArray count])) {
return nil;
}
YourPageContentViewController *dataViewController [[YourPageContentViewController alloc]initWithNibName:@"YourPageContentViewController" bundle:nil];
if (index%2 ==0) {
//set a background
dataViewController.backgroundImage = imageForLeftSide;
} else {
//set the other background
dataViewController.backgroundImage = imageForRightSide;
}
dataViewController.dataObject = [self.modelArray objectAtIndex:index];
return dataViewController;
}