OGeek|极客世界-中国程序员成长平台

标题: ios - UIViewControllers 在 UIPageViewController 中被重用 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 07:24
标题: ios - UIViewControllers 在 UIPageViewController 中被重用

我有一个 UIPageVIewController 并且我正在使用重用标识符初始化内部的 Controller ,即:

BaseContentViewController *contentViewController = (BaseContentViewController *)[self.storyboard instantiateViewControllerWithIdentifier:self.controllerRestorationIDs[index]];

我注意到了

if a UIViewController is reused then viewDidLoad is not called in that controller so any code that I want to be executed every single time the UIViewController appears won't.

例如,我想在每次出现时更改背景颜色。

UITableViewCell 有没有像 prepareForReuse 这样的方法,我可以把这段代码放进去?



Best Answer-推荐答案


我会把它放在 -viewWillAppear: 中。

关于ios - UIViewControllers 在 UIPageViewController 中被重用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30488410/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4