开发者

Objective C - Making UIAlertView wait for user input?

I have a UIAlertView set up with a textfield like so:

//***first set of code***  
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"User Input Required" message:@"Please enter data into the field" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];  
    [alert addTextFieldWithValue:nil label:@"[Enter Text]"];  
    [[alert textField] becomeFirstResponder];  
    [alert show];  
    [alert release];  
//***second set of code***`

How can I make it so that the user is required to click a button (I have that method already set up to send the input to a string) BEFORE any of the 'secon开发者_如何学Cd set of code' is fired off?

I need that second set of code to be contained in the same section as the alert (so I can't just run it within the 'dismissWithClickedButtonIndex' method) and that second set of code is using the string obtained from the user input, so that is why I don't want that code to run prior to the user clicking a button.


Don't you just love it when people say "don't do it that way"... and then never give you any good/correct way you SHOULD be doing it.

Thanks.


You can't do that. show message in UIAlertView won't stop for user input. Associated delegates will need to handle the code you are planning to put in //***second set of code*** section.

Having said that, let me give you some advice. addTextFieldWithValue message is an undocumented API feature. Do not use it. It used to be a long time ago that approval process from Apple for you APP would let you pass even if your application used that addTextFieldWithValue message. But nowadays that does not happen anymore. Your application will be automatically rejected if it is using that undocumented feature. Here is a blog entry on the topic.

Hope it helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜