// // UIAlertController+TextField.m // EZPlaySDKDemo // // Created by yuqian on 2018/10/22. // Copyright © 2018 yuqian. All rights reserved. // #import "UIAlertController+TextField.h" @implementation UIAlertController (TextField) + (UIAlertController *) showAlertVC:(NSString*)deviceSerial confirmHandler:(void(^)(NSString *code))handler { UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"视频流已加密,请输入密码" message:@"" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSString *pwd = alertVC.textFields.firstObject.text; if (pwd.length >= 6) { [[GlobalKit shareKit].deviceVerifyCodeBySerial setValue:pwd forKey:deviceSerial]; } if (handler) { handler(pwd); } }]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alertVC addAction:confirmAction]; [alertVC addAction:cancelAction]; [alertVC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { textField.placeholder = @"请输入密码"; }]; return alertVC; } @end