我在Xcode中有一个基于页面的应用程序,我正在尝试将其设置为使左侧页面和右侧页面在横向模式下具有不同的布局。
具体来说,如果页面在左侧,我想设置一个不同的页面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;
}