// // QRCodeInputPopupView.m // kneet // // Created by Jason Lee on 5/18/15. // Copyright (c) 2015 ntels. All rights reserved. // #import "JDObject.h" #import "RequestHandler.h" #import "JDJSONModel.h" #import "CustomLabel.h" #import "CustomTextField.h" #import "DeviceModel.h" #import "QRCodeInputPopupView.h" #import "ValidateUtil.h" @interface QRCodeInputPopupView () { } @end @implementation QRCodeInputPopupView - (id)initFromNib { for (UIView *view in [CommonUtil nibViews:@"QRCodeInputPopupView"]) { if ([view isKindOfClass:[QRCodeInputPopupView class]]) { self = (QRCodeInputPopupView *)view; //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함. self.frame = [UIScreen mainScreen].bounds; NSLog(@"%s\n %@", __PRETTY_FUNCTION__, self.popUpView); self.lblTitle.text = NSLocalizedString(@"활성화 코드 직접 입력",nil); _txtActivationCode.keyboardType = UIKeyboardTypeDefault; _txtActivationCode.returnKeyType = UIReturnKeyDone; _txtPasswd.delegate = self; _txtPasswd.secureTextEntry = YES; _txtPasswd.keyboardType = UIKeyboardTypeDefault; _txtPasswd.returnKeyType = UIReturnKeyDone; _txtActivationCode.placeholder = NSLocalizedString(@"활성화코드", @"활성화코드"); _txtPasswd.placeholder = NSLocalizedString(@"비밀번호", @"비밀번호"); [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal]; [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal]; } } return self; } - (void)didMoveToSuperview { self.txtActivationCode.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView; self.txtPasswd.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView; } #pragma mark - Main Logic #pragma mark - UI Events - (void)btnConfirmTouched:(id)sender { #if TARGET_IPHONE_SIMULATOR if (_qrcodeType == QRCodeTypeCommaxWallpad) { // _txtActivationCode.text = @"COMMAX_00-FF-B0-F5-5F-07"; // _txtActivationCode.text = @"COMMAX_12345678901234567890"; if ([_txtActivationCode.text isEmptyString]) { _txtActivationCode.text = @"COMMAX_201507070001"; } } else if (_qrcodeType == QRCodeTypeDawonSmartPlug) { if ([_txtActivationCode.text isEmptyString]) { _txtActivationCode.text = @"DAWON_20140213-0227"; } } #endif //1.validate if (![ValidateUtil validateTextfiled:_txtActivationCode type:ValidateTypeNull title:NSLocalizedString(@"활성화코드", @"활성화코드")]) { return; } if (![ValidateUtil validateTextfiled:_txtPasswd type:ValidateTypeNull title:NSLocalizedString(@"비밀번호", @"비밀번호")]) { return; } [super btnConfirmTouched:sender]; } #pragma mark - CustomTextField - (BOOL)textFieldShouldReturn:(UITextField *)textField { if ([textField isEqual:_txtPasswd]) { [self btnConfirmTouched:nil]; } return YES; } @end