I have an UIPageViewController, that i bring up programatically, i have overwritten the viewControllerBeforeViewController and the viewControllerAfterViewController methods to dinamically create the viewcontrollers after each flip. The problem is that when i don't complete the flip page movement and the previous view controller comes back to the view, the same view controller remains on the background of the view, messing with the content i am displaying. I have tried using the callback method of the UIPageViewController delegate pageViewController didFinishAnimating and inside this method, i get the messages i intend to get, so when an animation is not completed, i can react to it, but when i refresh the UIPageViewController by setting its current view controller, the problem persists, here is the code:
(void)pageViewController:(UIPageViewController *)pageViewController
didFinishAnimating:(BOOL)finished
previousViewControllers:(NSArray *)previousViewControllers
transitionCompleted:(BOOL)completed {
if (!completed)
{
[self viewDidAppear:NO];
for (UIViewController* vc in previousViewControllers) {
[self setViewControllers: @[vc]
direction: UIPageViewControllerNavigationDirectionForward
animated: NO
completion: nil];
}
return;
}
}
The question is: How can i "clean" or "refresh" or "clear" the content of my UIPageViewController to remove the residual view and only show the one that is intended.