【问题标题】:UITableView selectedBackgroundView not covering whole cellUITableView selectedBackgroundView 不覆盖整个单元格
【发布时间】:2014-05-15 13:35:33
【问题描述】:

我在 iOS7 故事板中使用静态单元格。单元格中有 UIButtons,它们依次调用“selectRowAtIndexPath”方法。

这不是一致的行为,仅当我在单元格之间切换时才会发生。

这里有问题的两个单元格有一个共同的超类。代码如下:

@implementation StudentMenuMultipleOptionsTableViewCell

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    if (!selected) {
        for (UIView *view in self.contentView.subviews) {
            if ([view isKindOfClass:[BlackBackgroundSelectedButton class]]) {
                BlackBackgroundSelectedButton *button = (BlackBackgroundSelectedButton *)view;
                button.selected = NO;
                [button setWhite];
            }
        }
    }
}

@end

【问题讨论】:

    标签: ipad cocoa-touch uitableview ios7 uistoryboard


    【解决方案1】:

    相当棘手。

    您需要确保没有对多个单元格使用相同的 UIView。视图在使用一次后会立即调整大小,并且会产生大小问题。

    解决方案是为每个单元格创建一个单独的背景视图,如下所示:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-28
      • 1970-01-01
      • 2011-09-15
      • 2023-03-22
      • 2016-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多