// // ModifiyDeviceNamePopupView.m // kneet // // Created by Jason Lee on 12/3/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 "ValidateUtil.h" #import "ModifyDeviceNamePopupView.h" @interface ModifyDeviceNamePopupView () { } @end @implementation ModifyDeviceNamePopupView - (id)initFromNib { for (UIView *view in [CommonUtil nibViews:@"ModifyDeviceNamePopupView"]) { if ([view isKindOfClass:[ModifyDeviceNamePopupView class]]) { self = (ModifyDeviceNamePopupView *)view; //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함. self.frame = [UIScreen mainScreen].bounds; _txtDeviceName.keyboardType = UIKeyboardTypeDefault; _txtDeviceName.returnKeyType = UIReturnKeyDone; [self.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)]; [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)]; [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)]; [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)]; [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)]; [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal]; [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal]; } } return self; } - (void)didMoveToSuperview { if (!self.superview) { return; } self.txtDeviceName.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView; } #pragma mark - Main Logic #pragma mark - UI Events - (void)btnConfirmTouched:(id)sender { //1.validate if (![ValidateUtil validateTextfiled:_txtDeviceName type:ValidateTypeNull title:@"장치명"]) { return; } if (_txtDeviceName.text.length > 20) { [[JDFacade facade] alert:@"장치명은 최대 20자까지 입력할 수 있습니다"]; return; } [super btnConfirmTouched:sender]; } #pragma mark - CustomTextField - (BOOL)textFieldShouldReturn:(UITextField *)textField { if ([textField isEqual:_txtDeviceName]) { [self btnConfirmTouched:nil]; } return YES; } @end