Objective C - 让UIAlertView等待用户输入?

wie*_*mon 0 iphone objective-c uialertview

我有一个UIAlertView设置文本字段如下:

//***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***`
Run Code Online (Sandbox Code Playgroud)

如何才能使用户需要单击一个按钮(我已经设置了该方法以将输入发送到字符串)之前的任何"第二组代码"被触发了?

我需要将第二组代码包含在与警报相同的部分中(因此我不能在'dismissWithClickedButtonIndex'方法中运行它)并且第二组代码使用从用户输入获得的字符串,因此这就是为什么我不希望在用户点击按钮之前运行该代码.

Pat*_*cia 7

当人们说"不要那样做"时,难道你不喜欢它......然后永远不会给你任何好的/正确的方式,你应该这样做.

谢谢.