Malloc
Malloc

Reputation: 16276

putting the chosen value in a text field

when the user select an item in a pickerView and press OK button, i have to put the selected item in a UITextField, so in the IBAction of the OK button what should i put please ? thx in advance :) this is my OK button code :

-(IBAction)okButton{
    [billTotal setText:@"Hi"];//the text field name is billTotal, this didn't work :(

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 480);
    pickerView.transform = transform;
    [UIView commitAnimations];  
}

Upvotes: 0

Views: 1174

Answers (1)

DimGun
DimGun

Reputation: 111

Something like this:

...
NSInteger selectedRow = [picker selectedRowInComponent:0];
billTotal.text = [NSString stringWithFormat:@"%d", selectedRow];
...

This didn't work

Check if your outlet connected to text field, and that "okButton" selector is called

Upvotes: 1

Related Questions