0

这是我的问题:我已经在周模式下实现了一个日历,周之间的导航是使用UIPageViewControllerpagecurl 模式完成的(非常类似于 iPad 的标准日历)。除非用户中止页面导航,否则一切正常。因此,如果日历显示当前周并且用户用手指平移以显示下周但随后中止手势并且他没有翻页,则数据源仍将显示下周而不是停留在当前周。

我尝试使用该方法

        - (void)pageViewController:(UIPageViewController *)pageViewController    
                didFinishAnimating:(BOOL)finished 
           previousViewControllers:(NSArray*)previousViewControllers
               transitionCompleted:(BOOL)completed

并检测 pangesture 何时中止,然后手动重置以前的视图控制器,但结果一点也不好。

这是我的数据源和委托方法的代码

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
      viewControllerBeforeViewController:(UIViewController *)viewController
{
    if (_pageIsAnimating) {
        return nil;
    }    
    [[MCalendarManager sharedCalendar] previousWeek];

    MCalendarContentViewController * contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"CalendarContentViewController"];

    return contentViewController;
}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
       viewControllerAfterViewController:(UIViewController *)viewController
{
    if (_pageIsAnimating) {
        return nil;
    } 


    [[MCalendarManager sharedCalendar] nextWeek];

    MCalendarContentViewController * contentViewController = [self.storyboard  instantiateViewControllerWithIdentifier:@"CalendarContentViewController"];


    return contentViewController;
}

- (void)pageViewController:(UIPageViewController *)pageViewController  willTransitionToViewControllers:(NSArray *)pendingViewControllers
{
    _pageIsAnimating = YES;
}

- (void)pageViewController:(UIPageViewController *)pageViewController
        didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers
       transitionCompleted:(BOOL)completed
{

    if (completed || finished) {  // Turn is either finished or aborted
        _pageIsAnimating = NO;
    }

    if (finished && !completed) {//Turn is aborted

        //Do something here for not changing the viewcontroller
    }
}

有谁知道如何解决这个问题?

提前致谢。

问候

4

0 回答 0