码迷,mamicode.com
首页 > 其他好文 > 详细

UIAlertViewController+TextField 输入框

时间:2015-12-14 14:04:06      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:

    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>0?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 输入框

标签:

原文地址:http://www.cnblogs.com/niit-soft-518/p/5044867.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!