Cycling from last to first (and vice versa) with UIPageViewController

邮差的信 提交于 2019-12-22 11:33:30

问题


I have two view controllers, let's call them transmit and receive. They are instantiated from storyboard in my parent view controller's viewDidLoad, and the first one is initially added to a UIPageViewController.

I've also set up a data source for the page view controller, with the following methods:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
        viewControllerAfterViewController:(UIViewController *)viewController {
    if ([viewController class] == [PRTransmitViewController class]) {
        return self.receiveViewController;
    }
    else {
        return self.transmitViewController;
    }
}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
        viewControllerBeforeViewController:(UIViewController *)viewController {
    if ([viewController class] == [PRReceiveViewController class]) {
        return self.transmitViewController;
    }
    else {
        return self.receiveViewController;
    }
}

My question is: is it OK to arrange an endless cycle like this? As I understand, the currently presented view controller is replaced and the previous one is unloaded. Do you anticipate any memory management problems with this arrangement as the user goes from screen to screen in a loop?

来源:https://stackoverflow.com/questions/16239868/cycling-from-last-to-first-and-vice-versa-with-uipageviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!