看來,UIPageViewController永遠持有初始內容視圖控制器。 例如:UIPageViewController內存泄漏
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;
的startingViewController永遠不會釋放,直到pageViewController它本身釋放。
要重現此錯誤,只需使用基於頁面的應用程序模板在XCode中創建一個新項目。並加入3行代碼爲DataViewController.m
@property NSInteger debugIndex; // file scope
NSLog(@"DataViewController[%d] created", self.debugIndex); // in viewDidLoad
NSLog(@"DataViewController[%d] dealloc", self.debugIndex); // in dealloc
而當你在滾動垂直方向的演示應用程序,你會得到這樣的記錄:
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]是從未釋放。
對此有何想法? 謝謝!
你有沒有找到解決這個與ARC解決呢? – 2013-11-06 16:45:53