简体   繁体   English

什么时候被称为:-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

[英]when is this called : - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

When is cellForRowAtIndexPath called when the cells of a TableViewController are added dynamicall? 在动态添加TableViewController的单元格时,何时调用cellForRowAtIndexPath? Is it after ViewDidLoad? 是在ViewDidLoad之后吗? We never trigger anything programatically to tell the app that we have done all the initial work we need to do and now you can start adding the cells with the corresponding details, discousure etc... 我们从不以编程方式触发任何事情来告诉应用程序我们已经完成了所有需要做的初始工作,现在您可以开始添加具有相应详细信息,不一致性等的单元格了。

I am terribly confused and therefore I have no clue about the flow of execution of controls in a TableViewController. 我非常困惑,因此我对TableViewController中控件的执行流程一无所知。 Please help me ! 请帮我 !

The delegate calls for the tableView will only be called if the table exists, for the table to exist the view must exist as it is part of the view. 仅当表存在时才调用对tableView的委托,要使该表存在,视图必须存在,因为它是视图的一部分。 The viewDidLoad is called right after creating the view. 创建视图后立即调用viewDidLoad。 So in short: viewDidLoad is called BEFORE tableView:cellForRowAtIndexPath: . 简而言之: viewDidLoad被称为tableView:cellForRowAtIndexPath:之前

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath is a delegate method of a UITableView . - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPathUITableView的委托方法。 It is called every time a cell is becoming visible(appearing on the screen due to scrolling for example). 每当一个单元格变得可见时(例如,由于滚动而出现在屏幕上),就会调用它。

And at the beginning it is called after viewDidLoad as many times as necessary(depending how many cells should be present). 并在开始时根据需要多次调用viewDidLoad (取决于应存在多少个单元格)。

Hope it helps 希望能帮助到你

it is called after viewDidLoad, and yes it is called for every cell dynamically. 在viewDidLoad之后调用它,是的,它为每个单元动态地调用。 you can put breakpoints and check the flow. 您可以放置​​断点并检查流程。 hope it helps. 希望能帮助到你。 happy coding :) 快乐的编码:)

The tableview knows that when it's unarchived it needs to load its data. tableview知道,在取消存档时,需要加载其数据。

As a general tip, if you want to know when a method is executed you can set a breakpoint. 作为一般提示,如果您想知道何时执行方法,可以设置一个断点。 Xcode lets you choose whether to pause or continue when a breakpoint is met, so you can trigger a set of actions when different methods are encountered to find out what order thet occur in. Xcode允许您选择在遇到断点时是暂停还是继续,因此,当遇到不同的方法以找出发生的顺序时,您可以触发一组操作。

暂无
暂无

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

相关问题 -未调用(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath - - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath is not being called func tableView(tableView:UITableView,cellForRowAtIndexPath indexPath:NSIndexPath)中的一个标准headCell上的不同方法-> UITableViewCell { - different methods on one standard headCell in func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ 使用-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath时出现黑屏 - Black Screen when using -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath UITableView tableView:cellForRowAtIndexPath:没有被调用 - UITableView tableView:cellForRowAtIndexPath: not getting called tableView(_ tableView:UITableView,didSelectRowAt indexPath:IndexPath)将UITapGestureRecognizer添加到自定义UITableViewCell时不起作用 - tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) Doesn't work when I add a UITapGestureRecognizer to my custom UITableViewCell 在UITableViewController子类中未调用tableView(_ tableView:UITableView,cellForRowAt indexPath:IndexPath) - tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) not getting called in UITableViewController subclass tableview方法func tableView(tableView:UITableView,editActionsForRowAtIndexPath indexPath:NSIndexPath)-> [UITableViewRowAction]问题? - Issue with tableview method func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? UITableView:`tableView:cellForRowAtIndexPath:`并非对所有行都调用 - UITableView: `tableView:cellForRowAtIndexPath:` not called for all rows tableView:在删除项目后使用nil indexPath调用cellForRowAtIndexPath - tableView:cellForRowAtIndexPath called with nil indexPath after deleting item 未调用UITableView更新器函数((UITableview)tableview cellForRowAtIndexPath) - UITableView updater function not being called ( (UITableview) tableview cellForRowAtIndexPath )
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM