UIAlertController UITextField
来源:互联网 发布:数码宝贝网络侦探存档 编辑:程序博客网 时间:2024/05/16 08:26
-(void)alterUsername{ /** * 弹出提示框 */ //初始化提示框 UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"给自己起个特别的昵称吧!" message:nil preferredStyle:UIAlertControllerStyleAlert]; [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.text = self.lblUsername.text; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(alertTextFieldDidChange:) name:UITextFieldTextDidChangeNotification object:textField]; }]; [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action){ NSLog(@"alterUsername"); }]]; [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]]; [self presentViewController:alert animated:YES completion:nil];}- (void)alertTextFieldDidChange:(NSNotification *)notification{ UIAlertController *alertController = (UIAlertController *)self.presentedViewController; if (alertController) { UITextField *login = alertController.textFields.firstObject; UIAlertAction *okAction = alertController.actions.firstObject; for (UIAlertAction *okAction in alertController.actions) { NSLog(@"%@",okAction); } okAction.enabled = login.text.length >= 1 && login.text.length <= 10; } }
0 0
- UIAlertController UITextField
- UIAlertController 添加 UITextField
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIalertController
- UIAlertController
- UIalertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- 查看内存
- 求最大值....
- 两个按钮点击,点击1,2的颜色切换,点击2,1的颜色切换?
- Eclipse+Maven创建webapp项目
- ListView中限制选择(checkbox)数目的Adapter
- UIAlertController UITextField
- 冒泡(bubble)排序算法
- Linux crontab 的脚本疯狂的重复运行
- 背包问题《1》01背包
- 构造函数的种类及之间的区别(C#)
- 判断设备的版本
- java学习笔记-java jvm内存结构分析
- 技术书籍
- scanf一些值得注意的问题