ModifyDeviceNamePopupView.m 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // ModifiyDeviceNamePopupView.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 12/3/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "JDJSONModel.h"
  11. #import "CustomLabel.h"
  12. #import "CustomTextField.h"
  13. #import "DeviceModel.h"
  14. #import "ValidateUtil.h"
  15. #import "ModifyDeviceNamePopupView.h"
  16. @interface ModifyDeviceNamePopupView () <CustomTextFieldDelegate> {
  17. }
  18. @end
  19. @implementation ModifyDeviceNamePopupView
  20. - (id)initFromNib {
  21. for (UIView *view in [CommonUtil nibViews:@"ModifyDeviceNamePopupView"]) {
  22. if ([view isKindOfClass:[ModifyDeviceNamePopupView class]]) {
  23. self = (ModifyDeviceNamePopupView *)view;
  24. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  25. self.frame = [UIScreen mainScreen].bounds;
  26. _txtDeviceName.keyboardType = UIKeyboardTypeDefault;
  27. _txtDeviceName.returnKeyType = UIReturnKeyDone;
  28. [self.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  29. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  30. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  31. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  32. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  33. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  34. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  35. }
  36. }
  37. return self;
  38. }
  39. - (void)didMoveToSuperview {
  40. if (!self.superview) {
  41. return;
  42. }
  43. self.txtDeviceName.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  44. }
  45. #pragma mark - Main Logic
  46. #pragma mark - UI Events
  47. - (void)btnConfirmTouched:(id)sender {
  48. //1.validate
  49. if (![ValidateUtil validateTextfiled:_txtDeviceName type:ValidateTypeNull title:@"장치명"]) {
  50. return;
  51. }
  52. if (_txtDeviceName.text.length > 20) {
  53. [[JDFacade facade] alert:@"장치명은 최대 20자까지 입력할 수 있습니다"];
  54. return;
  55. }
  56. [super btnConfirmTouched:sender];
  57. }
  58. #pragma mark - CustomTextField
  59. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  60. if ([textField isEqual:_txtDeviceName]) {
  61. [self btnConfirmTouched:nil];
  62. }
  63. return YES;
  64. }
  65. @end