UIAlertViewController+TextField 输入框

    if (IOS8) {
UIAlertController *alertController=[UIAlertController alertControllerWithTitle:CustomLocalizedString(@"SetIp", nil) message:@"" preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
NSString *string=[[NSUserDefaults standardUserDefaults]stringForKey:KSETIP];
[textField setText:string.length>?string:@""]; }];
UIAlertAction *action=[UIAlertAction actionWithTitle:CustomLocalizedString(@"OK", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
str_ip=[alertController.textFields firstObject].text;
NSLog(@"设置的Ip=%@",str_ip);
[[NSUserDefaults standardUserDefaults]setObject:str_ip forKey:KSETIP];
[[NSUserDefaults standardUserDefaults]synchronize];
}];
UIAlertAction *action_cancel=[UIAlertAction actionWithTitle:CustomLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[self dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:action];
[alertController addAction:action_cancel];
[self presentViewController:alertController animated:YES completion:nil]; }

UIAlertViewController+TextField 输入框

上一篇:windows下大数据开发环境搭建(2)——Hadoop环境搭建


下一篇:网站开发进阶(四十四)input type="submit" 和"button"的区别