0
任何人都可以快速帮助我吗?我一直在玩这个小时,不明白为什么这不起作用?UILabel突出显示文字
我试图更新选定标签中的突出显示的文本(这是在UILabels之前定义的数组中引用)。
该方法由视图界面中来自UISlider的接收IBAction调用。
但是,当我从数组中检索所选的UILabel对象并设置其HIGHLIGHTED属性时,在视图界面上没有相应的反应。我的印象是,它应该使用下面的代码突出显示文本来自动重画视图。
PS:我的连接似乎都是正确的Interface Builder(即IBOutlet UILabels被正确映射/连接,触发此方法的UISlider通过IBAction连接)。
我错过了什么吗?
- (IBAction) changeHighlightedLabel: (id)sender
{
// Setup
UILabel *selectedLabel = [[UILabel alloc] init];
selectedLabel.highlightedTextColor = [UIColor greenColor];
// Interpret slider value and round to integer
UISlider *temp = sender;
float unroundedTempValue = [temp value];
float roundedTempValue = roundf(unroundedTempValue);
// Select the UILabel object from the UI Label array based on slider valuer
selectedLabel = [uiLabelArray objectAtIndex:roundedTempValue];
// Highlight the selected label
selectedLabel.highlighted = YES;
}
我也试着代...
selectedCountryLabel = [[uiCountryLabelArray objectAtIndex:roundedTempValue] isHighlighted];
...最后一行。仍然不起作用。
任何反馈或帮助吗?谢谢。