QMLeaveMessageCell.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // QMLeaveMessageCell.m
  3. // IMSDK-OC
  4. //
  5. // Created by haochongfeng on 2017/11/27.
  6. // Copyright © 2017年 HCF. All rights reserved.
  7. //
  8. #import "QMLeaveMessageCell.h"
  9. @interface QMLeaveMessageCell ()
  10. @end
  11. @implementation QMLeaveMessageCell
  12. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  13. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  14. if (self) {
  15. self.backgroundColor = [UIColor whiteColor];
  16. [self setUI];
  17. }
  18. return self;
  19. }
  20. - (void)setUI {
  21. self.fieldLabel = [[UILabel alloc] init];
  22. self.fieldLabel.frame = CGRectMake(15, 7, 100, 30);
  23. self.fieldLabel.backgroundColor = [UIColor clearColor];
  24. self.fieldLabel.font = [UIFont systemFontOfSize:14];
  25. self.fieldLabel.text = NSLocalizedString(@"title.phoneNumber", nil);
  26. self.fieldLabel.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
  27. [self.contentView addSubview:self.fieldLabel];
  28. self.textField = [[UITextField alloc] init];
  29. self.textField.frame = CGRectMake(15 + 100, 7, RQ_SCREEN_WIDTH - 30 - 100, 30);
  30. self.textField.backgroundColor = [UIColor clearColor];
  31. self.textField.textAlignment = NSTextAlignmentRight;
  32. self.textField.font = [UIFont systemFontOfSize:16];
  33. self.textField.placeholder = NSLocalizedString(@"title.selection", nil);
  34. [self.contentView addSubview:self.textField];
  35. [self.textField addTarget:self action:@selector(change:) forControlEvents:UIControlEventEditingChanged];
  36. }
  37. - (void)setData: (NSDictionary *)information defaultValue: (NSString *)value {
  38. self.textField.text = @"";
  39. if (information[@"name"]) {
  40. self.fieldLabel.text = information[@"name"];
  41. }
  42. if (information[@"required"]) {
  43. BOOL required = [[information objectForKey:@"required"] boolValue];
  44. if (required == YES) {
  45. self.textField.placeholder = NSLocalizedString(@"title.required", nil);
  46. }else {
  47. self.textField.placeholder = NSLocalizedString(@"title.selection", nil);
  48. }
  49. }else {
  50. self.textField.placeholder = NSLocalizedString(@"title.selection", nil);
  51. }
  52. if (value) {
  53. self.textField.text = value;
  54. }
  55. }
  56. - (void)change: (UITextField *)textF {
  57. self.backInformation(textF.text);
  58. }
  59. - (void)awakeFromNib {
  60. [super awakeFromNib];
  61. // Initialization code
  62. }
  63. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  64. [super setSelected:selected animated:animated];
  65. // Configure the view for the selected state
  66. }
  67. @end