ModifyDeviceNamePopupView.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  29. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  30. }
  31. }
  32. return self;
  33. }
  34. - (void)didMoveToSuperview {
  35. if (!self.superview) {
  36. return;
  37. }
  38. self.txtDeviceName.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  39. }
  40. #pragma mark - Main Logic
  41. #pragma mark - UI Events
  42. - (void)btnConfirmTouched:(id)sender {
  43. //1.validate
  44. if (![ValidateUtil validateTextfiled:_txtDeviceName type:ValidateTypeNull title:@"장치명"]) {
  45. return;
  46. }
  47. if (_txtDeviceName.text.length > 20) {
  48. [[JDFacade facade] alert:@"장치명은 최대 20자까지 입력할 수 있습니다"];
  49. return;
  50. }
  51. [super btnConfirmTouched:sender];
  52. }
  53. #pragma mark - CustomTextField
  54. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  55. if ([textField isEqual:_txtDeviceName]) {
  56. [self btnConfirmTouched:nil];
  57. }
  58. return YES;
  59. }
  60. @end