这是我的问题:我在星期模式下实现了一个日历,在页面模式下使用UIPageViewController
完成了几周之间的导航(非常类似于iPad的标准日历)。除非用户中止页面导航,否则一切正常。
因此,如果日历显示当前周并且用户手指在下周显示,但随后中止手势并且他没有翻页,则数据源仍将显示下周,而不是停留在当前周。< / p>
我尝试使用方法
- (void)pageViewController:(UIPageViewController *)pageViewController
didFinishAnimating:(BOOL)finished
previousViewControllers:(NSArray*)previousViewControllers
transitionCompleted:(BOOL)completed
并检测何时中止pangesture然后手动重置前一个viewcontroller但结果并不好。
这是我的数据源和委托方法的代码
- (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
}
}
有没有人知道如何解决这个问题?
提前致谢。
此致