0

In Xcode 4.3 3, I created a button that generates a popup input box with (buttons Cancel & Enter), works ok, how do I retrieve the data entered and display it in a label or a table?

Here is how the code behind my button looks like.

- (IBAction)car:(UIButton *) sender NSString * title1 = [sender titleForState:UIControlStateNormal]; _mylabel.text = title1; UIAlertView *prompt = [[UIAlertView alloc] initWithTitle:@"Expense Amount in $:" message:@"\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Enter", nil]; _textField = [[UITextField alloc] initWithFrame:CGRectMake(12, 50, 260, 25)]; [_textField setBackgroundColor:[UIColor whiteColor]]; [_textField setPlaceholder:@"Amount"]; [prompt addSubview:_textField]; _textField.keyboardType = UIKeyboardTypeNumberPad; // show the dialog box [prompt show]; // set cursor and show keyboard [_textField becomeFirstResponder]; } 

Thank you for your help.

2 Answers 2

1

As introduced in iOS 5, you should use the UIAlertViewStylePlainTextInput style. You will get your value right in the delegate methods. Don't use a custom textfield anymore.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi jaydee3, thx for your response, I'm new to all this, could help me on how the implementation of this goes? Thx again.
see this tutorial for implementation: mobile.tutsplus.com/tutorials/iphone/…
0

What you are trying to solve here is a regular UITextField input data save, regardless of the alert view. You can accomplish that in different ways and with the use of the UITextField delegate methods:

textFieldDidChange textFieldDoneEditing textFieldShouldReturn 

Just implement saving the input data in one of those methods, depends on the desired user experience.

1 Comment

Hey TommyG, Yes I'am trying to save the input data from a popup input box, not from a regular UITextField. Thx

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.