Note that there are some explanatory texts on larger screens.

plurals
  1. POUIPageViewController - Verifying Page Turn with alert
    text
    copied!<p>I'm using a UIPageViewController to handle data entry where the last page is the active record and the previous pages are old records that can't be edited. So I need a way to verify that the user wants to leave the last page while allowing all of the other pages to navigate as usual.</p> <p>Ideally I could really use a -(BOOL)pageShouldTurn method but that doesn't exist.</p> <p>Does anyone know of a way to detect if a page is about to unload then stop the page turn based on some condition? I'm not having any luck with the gesture recognizer methods as they don't seem to be triggered even when the delegate is set.</p> <p>Thanks to Michael, I've added this to my pageViewController which does exactly what I needed:</p> <pre><code>-(void)pageViewController:(UIPageViewController *)pvc willTransitionToViewControllers:(NSArray *)pendingViewControllers { if ([pvc.viewControllers.lastObject pageIndex] == [self.pageDataSource.allObjects count]) { UIAlertView *alertDialog; alertDialog = [[UIAlertView alloc] initWithTitle:@"Are You Done?" message:@"Once you leave this page you can't edit this record again" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alertDialog show]; } } </code></pre> <p>So the alert box stops the page from turning only once. When it is dismissed, the user can then change the page. My version checks to make sure this only happens on the last page, you could remove the 'if' statement and alert on every page turn, but that would be annoying.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload