ModifyDeviceNamePopupView.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. self.txtDeviceName.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  36. }
  37. #pragma mark - Main Logic
  38. #pragma mark - UI Events
  39. - (void)btnConfirmTouched:(id)sender {
  40. //1.validate
  41. if (![ValidateUtil validateTextfiled:_txtDeviceName type:ValidateTypeNull title:@"이름"]) {
  42. return;
  43. }
  44. [super btnConfirmTouched:sender];
  45. }
  46. #pragma mark - CustomTextField
  47. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  48. if ([textField isEqual:_txtDeviceName]) {
  49. [self btnConfirmTouched:nil];
  50. }
  51. return YES;
  52. }
  53. @end