2016-07-12 42 views

回答

3

請使用此代碼,它將幫助你

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    currentIndex = 0; 
    self.delegate = self; 
    self.dataSource = self 
    // setup time interval here 

    [NSTimer scheduledTimerWithTimeInterval:10.0 
            target:self 
            selector:@selector(loadNextController) 
            userInfo:nil 
            repeats:YES]; 

    // set main controller 
    NSArray *mainViewControllers = @[[self viewControllerAtIndex:self.index]]; 

    [self setViewControllers: startingViewControllers 
        direction: UIPageViewControllerNavigationDirectionForward 
        animated: YES 
        completion: nil]; 
} 
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController 
{ 
    return currentIndex; 
} 

- (void)loadNextController { 

    PageContentViewController *nextViewController = [self viewControllerAtIndex:currentIndex++]; 
    if (nextViewController == nil) { 

     currentIndex = 0; 
     nextViewController = [self viewControllerAtIndex:currentIndex]; 
    } 

    [self setViewControllers:@[nextViewController] 
        direction:UIPageViewControllerNavigationDirectionForward 
        animated:YES 
        completion:nil]; 
} 
+0

謝謝你先生..它的工作 –

+0

感謝它的工作,但對我來說,我做了++ currentIndex在loadNextController – RameshIos

+0

它爲我工作++ currentIndex in loadNextController方法 – Rishi

-1

如果PageViewController在故事板創建:

設置轉換風格在左側菜單的滾動。

enter image description here

如果PageViewController編程創建:

- self.pageViewController.transitionStyle =UIPageViewControllerTransitionStyle.Scroll

相關問題