ios - CollectionViewCell 中的 Tableview

标签 ios objective-c uitableview uicollectionview

有没有人有在 collectionViewCell 中使用 tableView 的经验?

我在 collectionViewCell 中有一个 tableview(每个都是全屏 View )。每个 collectionViewCell 显示其自己的唯一数据。您可以在每个 collectionViewCell 之间水平滚动。 tableview 有一个带有几个标签的自定义 tableviewCell。我正在使用 tableview 来利用内置的 tableview 重新排序功能。

第一个 collectionViewCell 加载良好,数据在 tableview 中正确显示。但是,当我在 collectionView 单元格之间滚动时,tableView 为空(仅在标签中显示占位符文本),直到 collectionViewCell 停止滚动,然后 tableview 突然出现正确的数据。

关于如何确保 tableview 在显示之前已经填充了正确的数据,有什么建议吗?我需要它已经存在,因为用户将下一个 collectionViewCell 拖过(就像背景图像/标题文本已经存在一样)。

Here's a link to my project so you can see the code.

感谢任何帮助!

最佳答案

我没有那样做的经验。

但我认为您可以减少创建对您的单元格的引用的问题。所以你的手机不会被释放。您可以使用数组来做到这一点。

编辑:

您的问题是您正在使用计时器更新 TableViewCell

中的标签

你可以改变这个:

if (!timer) {
        timer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(updateLabels:) userInfo:nil repeats:YES];
    }

为此:

[self updateLabels:nil];

并为此更改您的 updateLabels::

- (void)updateLabels:(NSTimer *)_timer
{
    if (!timer) {
        timer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(updateLabels:) userInfo:nil repeats:YES];
    }

    unitOfTimeLabel.text = nameOfTimeLabel;

    if ([nameOfTimeLabel isEqualToString:@"Days"]) amountOfTimeLabel.text = [self daysRemaining];
    if ([nameOfTimeLabel isEqualToString:@"Hours"]) amountOfTimeLabel.text = [self hoursRemaining];
    if ([nameOfTimeLabel isEqualToString:@"Minutes"]) amountOfTimeLabel.text = [self minutesRemaining];
    if ([nameOfTimeLabel isEqualToString:@"Seconds"]) amountOfTimeLabel.text = [self secondsRemaining];
}

关于ios - CollectionViewCell 中的 Tableview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20485422/

相关文章:

ios - AirPlay 菜单在 iOS 6 上以纵向显示不正确

ios - 选择时自定义标签栏图标不是 "filled in"

ios - 如何获得高质量的 iOS 屏幕截图?

ios - 将行插入到 UITableView 的顶部会导致行向下移动,从而导致动画效果不佳

ios - 在 iOS 中根据数组中的值自动更新 UiLabels

android - 如何在 Android 和 iOS 中关闭 SSL 3.0?

ios - 使用 PFUser.getCurrentUserInBackground() 时出错

ios - 在 whatsapp 中分享多个视频

ios - 如何为 TableView 处理任意大量数据? (iOS/Objective-C)

iphone - 具有不同值的 TableView 委托(delegate)方法中的索引路径