2
此前已询问过此问题的位置:Get input value from TextField in iOS alert in Swift。但是,有人拥有Objective-C语言的代码吗?如何在警报中从TextField中获取输入文本
在此先感谢!
我到目前为止已经得到:
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Adding A Row"
message:@"Enter A Number"
preferredStyle:UIAlertControllerStyleAlert];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"";
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
//Do some action here
}];
[alert addAction:cancel];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
这不应该太难翻译。到目前为止,Objective-C代码的哪一部分?你是否已经创建了一个'UIAlertController'?你有没有添加文本框? – luk2302
我已经添加了一个文本框。遇到问题:// 3。从文本字段获取值,并在用户单击确定时打印。 (0)(0)(0)(0)收藏文章登录我的社区来说两句吧...表情删除后不可恢复,是否删除取消确定图片正在上传,请稍后...若前些页面显示空白,你可以按<确定>键。 textField.text)“) })) – Jay
好的,请显示您已获得的代码以及您认为需要帮助的地方,如果显示您的代码,将很乐意提供一些代码。 – luk2302