我看到包含带有省略号的UILabel的UITableViewCells发生了一些非常奇怪的事情(此项目仅适用于iOS 7)。我在首次加载tableView时看到省略号。然后,如果我按一个单元格,则文本+省略号的颜色将发生更改,就像我在setHighlighted函数中要求的那样。但是,当我释放它时(无论是我进入详细信息viewController并返回到带有表视图的第一个viewController,还是只是按下然后滚动以松开突出显示),省略号都消失了。
实际上,我发现它仍然存在,只是在白色背景上是白色(文本突出显示的颜色,请参见底部的代码)。为了更好地理解,以下屏幕显示了我刚刚描述的内容:
点击之前:
在单击时,该单元格突出显示:
单击后,移至下一个viewController并按back:
请注意,如果我单击并通过滚动松动突出显示,则仅突出显示的单元格会松开省略号。另外,在滚动tableView时,一切都很好,直到到达底部为止,并加载列表的下一个元素-然后所有的省略号都保持白色(还有突出显示的字体,即黑体)。这使我相信,这是由于在重新加载单元格数据时执行的某些操作引起的。
这是setHighlighted的代码:
-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
NSUInteger fontSize = _titleLabel.font.pointSize;
[UIView animateWithDuration:(highlighted ? .2 : .5)
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
_background.backgroundColor = (highlighted ? [UIColor blueND] : [UIColor whiteColor]);
_hourLabel.textColor = (highlighted ? [UIColor whiteColor] : [UIColor blackColor]);
_titleLabel.textColor = (highlighted ? [UIColor whiteColor] : [UIColor blackColor]);
_titleLabel.font = (highlighted ? [UIFont boldSystemFontOfSize:fontSize] : [UIFont systemFontOfSize:fontSize]);
_consoleLabel.textColor = (highlighted ? [UIColor blueND] : [UIColor whiteColor]);
_consoleLabel.backgroundColor = (highlighted ? [UIColor whiteColor] : [UIColor blueND]);
}
completion:nil];
}
有人知道这里发生了什么吗?
提前谢谢你的帮助 !
更新:根据Leo Natan的评论,这是突出显示的单元格的_titleLabel.attributedString的结果,一旦突出显示,然后发布:
(lldb) po _titleLabel.attributedText
Mario Golf : World Tour, le Lagon Cheep Cheep en vidéo{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICTFont: 0x1669a990> font-family: \".HelveticaNeueInterface-Regular\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
NSParagraphStyle = "Alignment 0, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 4, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSShadow = "NSShadow {0, -1} color = {(null)}";
}
这可能是系统的错误。确保打开错误报告。
正如注释中所设计的那样,您可以使用标签的“highlightedTextColor
和单元格”selectedBackgroundView
来实现自己尝试的方式,而不必手动设置颜色。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句