Removing a view controller from UIPageViewController

前端 未结 12 2500
梦谈多话
梦谈多话 2020-11-28 19:22

It\'s odd that there\'s no straightforward way to do this. Consider the following scenario:

  1. You have a page view controller with 1 page.
  2. Add another p
12条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 19:45

    I'll put this answer here just for my own future reference and if it helps anyone - what I ended up doing was:

    1. Delete the page and advance to the next page
    2. In the completion block of setViewControllers, I created/init'ed a new UIPageViewController with the modified data (item removed), and pushed it without animating, so nothing changes on-screen (my UIPageViewController is contained within a UINavigationController)
    3. After pushing the new UIPageViewController, get a copy of the viewControllers array of the UINavigationController, remove the second-to-last view controller (which is the old UIPageViewController)
    4. There is no step 4 - done!

提交回复
热议问题