Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 从UIAlertView检索输入文本_Iphone_Objective C_Ios_Uialertview - Fatal编程技术网

Iphone 从UIAlertView检索输入文本

Iphone 从UIAlertView检索输入文本,iphone,objective-c,ios,uialertview,Iphone,Objective C,Ios,Uialertview,在Xcode 4.3中,我创建了一个按钮,该按钮生成一个弹出式输入框,带有(按钮Cancel&Enter),工作正常,如何检索输入的数据并将其显示在标签或表格中 下面是我按钮后面的代码的样子 - (IBAction)car:(UIButton *) sender NSString * title1 = [sender titleForState:UIControlStateNormal]; _mylabel.text = title1; UIAlertVie

在Xcode 4.3中,我创建了一个按钮,该按钮生成一个弹出式输入框,带有(按钮Cancel&Enter),工作正常,如何检索输入的数据并将其显示在标签或表格中

下面是我按钮后面的代码的样子

- (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];


}

感谢您的帮助。

正如iOS 5中介绍的那样,您应该使用
UIAlertViewStylePlainTextInput
样式。您将在委托方法中获得正确的值。不要再使用自定义文本字段。

无论警报视图如何,您试图解决的问题是定期保存UITextField输入数据。您可以通过不同的方式并使用UITextField委托方法来实现这一点:

textFieldDidChange
textFieldDoneEditing
textFieldShouldReturn

只需实现在其中一种方法中保存输入数据,这取决于所需的用户体验

嘿,TommyG,是的,我正在尝试从弹出式输入框保存输入数据,而不是从常规UITextField保存输入数据。ThxHi Jayde3,thx感谢您的回复,我对这一切都不熟悉,能帮我了解一下这项技术的实施情况吗?再次使用Thx。有关实现,请参阅本教程: