UITableView reloadData似乎不会导致cellForRowAtIndexPath:被调用 [英] UITableView reloadData does not seem to cause cellForRowAtIndexPath: to be called

查看:79
本文介绍了UITableView reloadData似乎不会导致cellForRowAtIndexPath:被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用故事板编写一个应用程序,该应用程序在同一窗口中包含两个 UITableView



当运行应用程序时,第一个 UITableView 将填充一些注册号。



用户点击一个单元格,然后第二个 UITableView 应该填充有关选定单元格的详细信息。



点击第一个表中的数字我有一个方法驱动:

  [mySecondTableView reloadData] 

它的作用。我的印象是,当调用 reloadData 命令时,它应该调用两个:

   - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

第一次触发,但第二次不触发。
我有数据源和代理连线到自我。



我不知道我缺少什么。


$ b

解决方案

当这种情况发生在我身上时,在主线程之外调用 -reloadData


I am currently writing an app, using storyboards, that contains two UITableViews within the same window.

When running the application, the first UITableView will populate with a number of "Registration Numbers".

When the user taps on a cell, then the second UITableView is supposed to populate with detail about the selected cell.

When tapping a number in the first table I have a method that drives the:

[mySecondTableView reloadData]

Which it does. I am under the impression that when invoking the reloadData command, it should then call both:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

and

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

The first fires, but the second won't. I have both the data source and delegate wired to self.

I am not sure what I am missing.

Are both methods meant to fire?

解决方案

When things like this happen to me, it's usually because I'm calling -reloadData outside of the main thread.

这篇关于UITableView reloadData似乎不会导致cellForRowAtIndexPath:被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆