相关疑难解决方法(0)

PageViewController委托函数调用两次

我正在使用UIPageViewController,为我的应用程序进行产品导览.

我按照这个链接http://www.appcoda.com/uipageviewcontroller-tutorial-intro/

我正在做的是根据我获得的索引值在滑动时更改我的"根VC"的背景颜色的简单任务,但是由于委托函数被调用两次,我的索引值不正确,因此,我不是能够做对,下面是我的代码

#import "APPViewController.h"
#import "APPChildViewController.h"

@interface APPViewController ()

@end

@implementation APPViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];

    self.pageController.dataSource = self;
    [[self.pageController view] setFrame:CGRectMake(0, 0, 320, 500)];

    APPChildViewController *initialViewController = [self viewControllerAtIndex:0];

    NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];

    [self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

    [self addChildViewController:self.pageController];
    [[self view] addSubview:[self.pageController view]];
    [self.pageController didMoveToParentViewController:self];

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

}

- (APPChildViewController *)viewControllerAtIndex:(NSUInteger)index { …
Run Code Online (Sandbox Code Playgroud)

ios ios5 uipageviewcontroller ios6

12
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios ×1

ios5 ×1

ios6 ×1

uipageviewcontroller ×1