The UIPageViewController seems to hold the initial content view controller forever. For example:
DataViewController *startingViewController = [self.modelController viewControllerAtIndex:0 storyboard:self.storyboard]; NSArray *viewControllers = @[startingViewController]; [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL]; self.pageViewController.dataSource = self.modelController;
startViewController is never released until the pageViewController itself is released.
To reproduce this error, simply create a new project in Xcode using a page-based template. And add 3 lines of code to DataViewController.m.
@property NSInteger debugIndex; // file scope NSLog(@"DataViewController[%d] created", self.debugIndex); // in viewDidLoad NSLog(@"DataViewController[%d] dealloc", self.debugIndex); // in dealloc
And when you scroll through the demo app in vertical orientation, you will get the following logs:
DataViewController[0] created DataViewController[1] created DataViewController[2] created DataViewController[1] dealloc DataViewController[3] created DataViewController[2] dealloc DataViewController[4] created DataViewController[3] dealloc DataViewController[5] created DataViewController[4] dealloc DataViewController[6] created DataViewController[5] dealloc
DataViewController [0] is never freed.
Any ideas on this? Thank!
memory-leaks uipageviewcontroller
Jay Zhao Mar 01 '13 at 11:07 2013-03-01 11:07
source share