2012-08-31 31 views
0

我在Xcode中有一個基於頁面的應用程序,我試圖設置它,以便左側頁面和右側頁面在橫向模式下具有不同的佈局。UIPageViewController - 如何在橫向模式下自定義左右頁面?

具體來說,如果頁面位於左側,我想設置一個不同的頁面bg圖像,以便它看起來更像一本真正的書。

有沒有一種方法可以以編程方式檢測UIPageViewController在橫向模式下是左側還是右側?你將如何去解決這個問題?

回答

0

如果您有背景圖像的屬性,你可以改變它的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; 
} 
相關問題