数据源&在UIPageViewController中没有调用委托方法

时间:2018-06-12 15:02:13

标签: ios objective-c

我正在尝试在UICollectionReusableView上添加一个PageViewController。以下是我的代码

-(UICollectionReusableView*)supplementaryViewInCollectionView:(UICollectionView*)collectionView forTopViewAtIndexPath:(NSIndexPath*)indexPath {

    if (_accountView == nil) {
        AccountsView *accView = [collectionView dequeueReusableSupplementaryViewOfKind:CollectionViewTopViewKind withReuseIdentifier:CollectionViewTopViewKind forIndexPath:indexPath];

        if (accView.selectionDelegate == nil) {

            _accountView = accView;


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

            self.pageController.delegate = nil;
            self.pageController.dataSource = nil;
            self.pageController.delegate = self;
            self.pageController.dataSource = self;

            CGRect viewRect = accView.gradientView.frame;
            float cardWidth = (viewRect.size.width*80/100.0);
            float cardHeight = (viewRect.size.height);
            [[self.pageController view] setFrame: CGRectMake(0.0, 0.0, cardWidth, cardHeight)];
            [self.pageController view].center = CGPointMake(accView.gradientView.center.x, accView.gradientView.center.y + accView.gradientView.frame.size.height/3);

            APPChildViewController *initialViewController = [self viewControllerAtIndex:self.selectedIdex];

            NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];

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

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

        return accView;
    }

    return _accountView;
} 

我已宣布' pageController'对象如下面的viewController.h文件

@property (strong, nonatomic) UIPageViewController *pageController;

但是PageController的数据源&代表们不会在每次互动时被调用。

我试过这些链接

Link1 Link2等但无法取得成功。

请让我知道我在这里犯了什么错误。

0 个答案:

没有答案