开发者

label not updating with picker view

开发者 https://www.devze.com 2022-12-16 03:07 出处:网络
I have a pickerview pulling from a datasource.I have code to update a label in the didSelectRow function, but the label is not updating.When I print the value to the NSLog, the proper value is printed

I have a pickerview pulling from a datasource. I have code to update a label in the didSelectRow function, but the label is not updating. When I print the value to the NSLog, the proper value is printed. Is there something special I need to do to hookup the label so that it updates when the didSelectRow is eneter?

- (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 开发者_StackOverflow社区selectedRowInComponent:0]]]);

}

}


[pickerView selectedRowInComponent:0]

might be the source of your problem.

[description objectAtIndex:row] should work


If NSLog prints the correct value, there must be a problem with the label variable.

Print it using NSLog, see if it's a correct reference to your label?

Also, you may try calling [label setNeedsDisplay] after changing the text, although I'm not sure it's necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消