iphone - UIPageViewController: display error when user aborts pangesture -
here problem: i've implemented calendar in week mode, navigation between weeks done using uipageviewcontroller
in pagecurl mode (quite similar standard calendar of ipad). works except when user aborts page navigation. if calendar showing current week , user pan finger show next week aborts gesture , doesn't turn page, datasource still display next week instead of staying @ current week.
i tried using method
- (void)pageviewcontroller:(uipageviewcontroller *)pageviewcontroller didfinishanimating:(bool)finished previousviewcontrollers:(nsarray*)previousviewcontrollers transitioncompleted:(bool)completed
and detecting when pangesture aborted , manually reset previous viewcontroller result not @ all.
here code datasource , delegate methods
- (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 either finished or aborted _pageisanimating = no; } if (finished && !completed) {//turn aborted //do here not changing viewcontroller } }
does has idea how solve this?
thanks in advance.
regards
Comments
Post a Comment