CYEditTitleViewController.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //
  2. // CYEditTitleViewController.m
  3. // shiku_im
  4. //
  5. // Created by Ron on 2019/11/16.
  6. // Copyright © 2019 Reese. All rights reserved.
  7. //
  8. #import "CYEditTitleViewController.h"
  9. #import "CYActiveTitleViewController.h"
  10. @interface CYEditTitleViewController ()
  11. @property (nonatomic,strong) UIImageView * memberView;
  12. @property (nonatomic,strong) UITextField *memberAccountText;
  13. @property (nonatomic,strong) NSMutableArray *array;
  14. @end
  15. @implementation CYEditTitleViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view.
  19. self.isGotoBack = YES;
  20. self.title = @"编辑头衔";
  21. self.heightFooter = 0;
  22. self.heightHeader = JX_SCREEN_TOP;
  23. [self createHeadAndFoot];
  24. self.tableBody.scrollEnabled = YES;
  25. self.tableBody.contentSize = CGSizeMake(self_width, JX_SCREEN_HEIGHT - JX_SCREEN_TOP);
  26. self.tableBody.showsVerticalScrollIndicator = YES;
  27. int h = 0;
  28. [_memberView removeFromSuperview];
  29. _memberView = [[UIImageView alloc] initWithFrame:CGRectMake(0, h, JX_SCREEN_WIDTH, self.tableBody.frame.size.height)];
  30. _memberView.userInteractionEnabled = YES;
  31. _memberView.backgroundColor = HEXCOLOR(0xf0eff4);;
  32. [self.tableBody addSubview:_memberView];
  33. self.memberAccountText = [[UITextField alloc] initWithFrame:CGRectMake(0,1, JX_SCREEN_WIDTH, 40)];
  34. self.memberAccountText.borderStyle = UITextBorderStyleNone;
  35. self.memberAccountText.backgroundColor = [UIColor whiteColor];
  36. self.memberAccountText.placeholder = [NSString stringWithFormat:@" %@",self.rankTitle];
  37. self.memberAccountText.font = [UIFont systemFontOfSize:15];
  38. [self.memberAccountText addTarget:self action:@selector(memberAcountTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  39. [_memberView addSubview:self.memberAccountText];
  40. h+=_memberAccountText.frame.size.height;
  41. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, h, JX_SCREEN_WIDTH -40, 30)];
  42. label.backgroundColor = [UIColor clearColor];
  43. label.numberOfLines = 0;
  44. label.textColor = UIColor.blackColor;
  45. label.textAlignment = NSTextAlignmentLeft;
  46. label.text = [NSString stringWithFormat:@"请编辑%ld级成员头衔",_num];
  47. [_memberView addSubview:label];
  48. // button.customView.frame = CGRectMake(self_width-50, JX_SCREEN_TOP - 38, 65, 30);
  49. // UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH - JX_SCREEN_TOP - 38, 30, 40, 20)];
  50. // [button setTitle:@"确定" forState:UIControlStateNormal];
  51. // [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  52. // [button addTarget:self action:@selector(okClick) forControlEvents:UIControlEventTouchUpInside];
  53. // [self.tableHeader addSubview:button];
  54. UILabel *sureLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
  55. sureLabel.text = @"确定";
  56. UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:sureLabel];
  57. [sureLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(okClick)]];
  58. sureLabel.userInteractionEnabled = YES;
  59. [self setRightBarButtonItem:item];
  60. }
  61. -(void)memberAcountTextFieldDidChange:(UITextField *)send{
  62. // self.memberAccountStr = send.text;
  63. NSLog(@"title:%@",send.text);
  64. }
  65. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  66. [self.view endEditing:YES];
  67. }
  68. -(void)okClick{
  69. NSString *groupLevelName = self.memberAccountText.text;
  70. NSMutableArray *array = [NSMutableArray arrayWithArray:self.nameArr];
  71. [array replaceObjectAtIndex:_nameArr.count - self.num withObject:groupLevelName];
  72. NSArray *newArray = [[array reverseObjectEnumerator] allObjects];
  73. groupLevelName = [newArray componentsJoinedByString:@","];
  74. _array = newArray.copy;
  75. // 数组翻转
  76. // 发请求改头衔
  77. [g_server updateRoom:self.room key:@"groupLevelName" value:groupLevelName toView:self];
  78. }
  79. - (void)didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  80. if([aDownload.action isEqualToString:act_roomSet]){
  81. [g_notify postNotificationName:kgroupLevelNameRefresh object:_array];
  82. [g_navigation popToViewController:[CYActiveTitleViewController class] animated:YES];
  83. }
  84. }
  85. /*
  86. #pragma mark - Navigation
  87. // In a storyboard-based application, you will often want to do a little preparation before navigation
  88. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  89. // Get the new view controller using [segue destinationViewController].
  90. // Pass the selected object to the new view controller.
  91. }
  92. */
  93. @end