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];
...最後一行。仍然不起作用。
任何反饋或幫助嗎?謝謝。