1

我有一个从数据源中提取的pickerview。我有代码来更新 didSelectRow 函数中的标签,但标签没有更新。当我将值打印到 NSLog 时,会打印正确的值。我需要做一些特别的事情来连接标签,以便在 didSelectRow 进入时更新?

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
if (pickerView.tag == TagLensPicker){
    [self lensArrayData];
    label.text = [NSString stringWithFormat:@"%@",[description objectAtIndex:[pickerView selectedRowInComponent:0]]];
    NSLog([NSString stringWithFormat:@"%@", [description objectAtIndex:[pickerView selectedRowInComponent:0]]]);

}

}

4

2 回答 2

1
[pickerView selectedRowInComponent:0]

可能是您问题的根源。

[description objectAtIndex:row]应该管用

于 2010-01-10T17:04:43.543 回答
0

如果 NSLog 打印出正确的值,那么标签变量肯定有问题。

使用 NSLog 打印它,看看它是否是对您标签的正确引用?

另外,您可以在更改文本后尝试调用[label setNeedsDisplay],尽管我不确定是否有必要。

于 2010-01-10T17:31:43.513 回答