Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在视图加载之前运行一个函数,我尝试过initWithNibName但没有成功。有什么函数在渲染之前加载?
initWithNibName
这样做loadView:
loadView
- (void)loadView { [self myImportantMethod]; [super loadView]; }
这可以确保myImportantMethod在加载视图控制器的视图之前调用您的。
myImportantMethod
你试过initWithFrame吗?根据我的经验,其中一个是首先调用的。