In my view I have 2 TextFields, 1 Label, 1 Picker and 1 button
I want to the label to have the value of the 2 textfields and the selected value of the picker when the button is clicked.
The following is my button click code
-(IBAction)changeTheTextOfTheLabel
{
NSInteger row;
row = [listPicker selectedRowInComponent:0];
NSString *fullName = [[NSString alloc] initWithFormat:@"%@ %@ (%@)",firstNameTextView.text,lastNameTextView.text, [listArray objectAtIndex:row]];
[fullNameLabel setText:fullName];
[fullName release];
}
The above code work fine except that it always put the first item ofthe picker in the label no matter which row it was selected.
Thank you.
It doesn’t look like the instance variable
listPickeris connected to theUIPickerViewin IB.Here
rowwill always be zero iflistPickerisniland that should happen only whenlistPickeris not connected.