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>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];
       
    }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM