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
listPicker
is connected to theUIPickerView
in IB.Here
row
will always be zero iflistPicker
isnil
and that should happen only whenlistPicker
is not connected.