Unexpected UIPageViewController behaviour

ios, objective-c, uipageviewcontroller

Solution

I'm not sure what it is in your code that does this, but one probable approach in debugging this is to try and catch the `UITextField`'s `UIKeyboardWillShowNotification` event to check if it's firing properly.

Also try to set a breakpoint at your page's `viewWillAppear` event to inspect if all of the `UITextField`s have been instantiated properly -- I would suspect that at the point where you tapped the first text field not all of them have instantiated yet, meaning that the object receiving the tap action will be your `UIPageViewController` instead of the `UITextField`.

Problem

I'm currently building a app using `UIPageViewController`. It is working as I expected until it reaches last page which contains numbers of UITextField. But when I tapped one of instances of UITextField, it suddenly jumps to the previous page without any reason instead of showing a keyboard. When I scroll through to the last page and tap a text field again, it works well without any problem. It is also fine when it shows last page immediately by tapping the navigation button that links to the last page and that is attached to the UIPageViewController instance. This problem happens only when I scroll through pages from first to the last, and it happens only once at the first try. I suspected low memory issues, so I set breakpoints in -`didReceiveMemoryWarning` method of both UIPageViewController instance and the last page view controller. But they were never called. The second try is that I added a breakpoint in the last page view controller's `-willMoveToParentViewController:` method and set its condition to `parent == nil`(when it's removed from parent view controller, which is the UIPageViewController instance in question) When I run the app, the breakpoint's call stack says that the method is called by UIPageViewController's `-_flushViewController:animated:`. I don't know why this -flushViewController:animated: is called. If I can figure out the cause, it will help me with fixing the problem. Is there anybody who can help me?

Original source

Related problems