【发布时间】:2014-08-06 15:51:29
【问题描述】:
以下是我的应用如何将数据加载到 UITableView 中的顺序:
- UITableView 从空数组加载。
- 应用异步获取数据。
- 获取并处理数据后,应用调用 UITableView reloadData。
我目前遇到的问题是,我需要手动稍微滑动一下 UITableView,才能让 UITableView 显示获取到的数据。
目前我正在使用iOS模拟器进行测试。
这被认为是正常的吗?在没有用户请求滑动数据的情况下,我可以做些什么来显示数据?
-- 编辑--
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *tableCellIdentifier = @"TempTableViewCell";
TempTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:tableCellIdentifier forIndexPath:indexPath];
int row = [indexPath row];
YoutubeVideo *currentVideo = [videoArray objectAtIndex:row];
cell.TempLabel.text = currentVideo.VideoTitle;
[cell.TempImage setImageWithURL:[NSURL URLWithString:currentVideo.VideoThumbnailURL] placeholderImage:[UIImage imageNamed:@"Icon-Small"]];
cell.TempLabelDate.text = currentVideo.VideoDate;
return cell;
}
【问题讨论】:
-
您的滑动是否会导致单元格的重复使用?换句话说,在你滑动的时候有没有被替换的单元格?
-
我已经为 cellForRowAtIndexPath 添加了代码。
-
你可以尝试在
tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath中设置图片和文字吗? -
还是一样。你以前遇到过这样的事情吗?
-
我想你可以按照这里给出的解决方案stackoverflow.com/questions/2770158/…
标签: objective-c uitableview xcode5