2013-01-06 109 views
0

我閱讀了文檔,但是我仍然無法把頭圍繞在這個文檔上。我有一個導航VC,我設置了一個pageview VC作爲其根(它不會在ViewView控制器中的viewdidload中找到我的斷點)。迄今爲止所有事情都在故事板上完成試圖瞭解PageViewController

我現在在故事板中創建兩個新的viewcontrollers並與這兩個創建一個數組?他們從哪裏獲得VC的VC頁面?

謝謝。

下面是從pageviewcontroller一些代碼:(什麼也沒有發生,只是一個黑屏)

@implementation ResultsViewController

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.delegate=self; 
    self.dataSource=self; 

    NSMutableArray *array=[[NSMutableArray alloc]init]; 
    [array addObject:[[Page1ViewController alloc]init]]; 
    [array addObject:[[Page2ViewController alloc]init]]; 

    [self setViewControllers:[NSArray arrayWithArray:array] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil]; 
    // Do any additional setup after loading the view. 
} 
-(void)setViewControllers:(NSArray *)viewControllers direction:(UIPageViewControllerNavigationDirection)direction animated:(BOOL)animated completion:(void (^)(BOOL))completion{}; 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 
+0

它看起來像你已經覆蓋setViewControllers那裏,是這種情況? – jrturton

+0

不這麼認爲,只是添加它,因爲示例代碼有它...我沒有它試過,效果相同 –

回答

1

要獲得UIPageViewController是如何工作的使用故事板的想法,你應該創建一個新的項目,而不是選擇單一的視圖應用程序,只需選擇基於頁面的視圖應用程序,它會自動連接的一切,並從那裏你可以進一步自定義。

+0

好主意,謝謝 –