简体   繁体   English

在viewDidLoad之前调用UITableView委托方法

[英]UITableView delegate methods being called before viewDidLoad

I have a view controller that subclasses UITableViewController. 我有一个子类化UITableViewController的视图控制器。 When I push this VC onto the navigation stack, the UITableView delegate methods get called, then viewDidLoad gets called, then the delegate methods get called again. 当我将此VC推入导航堆栈时,将调用UITableView委托方法,然后调用viewDidLoad,然后再次调用委托方法。 What is going on here? 这里发生了什么?

Because your view is a subclass of UITableViewController, the delegate and datasource are attached from the very first moment it's created, and the methods are called as soon as the datasource is asigned. 由于您的视图是UITableViewController的子类,因此从创建委托和数据源的第一刻起便附加它,并且在分配数据源后立即调用方法。

Also, you can set a breakpoint on it and see which class called the datasource. 另外,您可以在其上设置一个断点,并查看哪个类称为数据源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM