gpt4 book ai didi

uitableview - iOS 7 中 UILabel 和 UILabel 的省略号颜色变化

转载 作者:行者123 更新时间:2023-12-04 12:08:16 25 4
gpt4 key购买 nike

我看到我的 UITableViewCells 上发生了一些非常奇怪的事情,其中​​包含带有省略号的 UILabels(该项目仅适用于 iOS 7)。我在 tableView 首次加载时看到省略号。然后,如果我按下一个单元格,文本 + 省略号的颜色会按照我在 setHighlighted 函数中的要求进行更改。但是当我释放它时(无论是当我转到详细信息 viewController 并返回带有表格 View 的第一个 viewController 时,或者只是按下然后滚动以松开突出显示),省略号消失了。

其实我发现还是有的,只是白底白字(文字高亮的颜色,见底部代码)。为了更好地理解,以下是显示我刚刚描述的内容的屏幕:

Before clicking :



Before clicking

The cell is highlighted while we click :



The cell is highlighted

After clicking, moving to the next viewController and pressing back :



After clicking, moving to the next viewController and pressing 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 的评论,这是突出显示单元格的 po _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以自己的方式实现您的目标。

关于uitableview - iOS 7 中 UILabel 和 UILabel 的省略号颜色变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22417077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com