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

标签 ios iphone ios7

如何实现 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/

相关文章:

iphone - 从 iPhone 创建全景 View

iOS7选择按钮边框效果

cocoa-touch - 在 iOS 应用中显示不受信任的证书信息

iphone - 模块与 ios 中的旧版本兼容吗?

ios - 如何从具有多个数组的字典中获取特定键并将其存储到放置在 TableView 单元格中的字符串中

iphone - 涉及 NSDocumentDirectory 和其他 iOS 应用程序特定调用的静态库的单元测试

ios - 在我的应用程序中模拟设备按钮?

ios - UILocalNotification询问用户权限

iOS Swift WKWebKit 与 MBCircularProgressBarView

ios - jasonett/iOS 的后退按钮