gpt4 book ai didi

ios - 如何使用 UIAlertViewStylePlainTextInput 在 ios 7 中使用 textfieldname.text 和 textfield.placeholder?

转载 作者:行者123 更新时间:2023-11-28 20:03:50 25 4
gpt4 key购买 nike

如何实现 ios 7 的 textfieldname.text 和 textfield.placeholder 功能?我使用了以下代码。

UIAlertView* dialog = [[UIAlertView alloc] init];
[dialog setDelegate:self];
[dialog setTitle:@"Title"];
[dialog setMessage:@" "];
[dialog addButtonWithTitle:@"OK"];
[dialog addButtonWithTitle:@"Cancel"];

[dialog setAlertViewStyle:UIAlertViewStylePlainTextInput];

[dialog show];

有时我想将一些数据加载到文本字段中,例如如果用户需要将“欢迎”加载到文本字段中,然后他们可以将测试修改为“欢迎使用 stackoverflow”。是否有可能实现该功能?提前感谢您的帮助。

最佳答案

UITextField *textField = [dialog textFieldAtIndex:0];
textField.text = @"Some Text";
textField.placeholder = @"Some Placeholder";

更多信息:https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html#//apple_ref/occ/instm/UIAlertView/textFieldAtIndex :

关于ios - 如何使用 UIAlertViewStylePlainTextInput 在 ios 7 中使用 textfieldname.text 和 textfield.placeholder?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22879497/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com