// // CYActiveTitleViewController.m // shiku_im // // Created by Ron on 2019/11/14. // Copyright © 2019 Reese. All rights reserved. // #import "CYActiveTitleViewController.h" #import "CYActiveTieleTableViewCell.h" #import "CYEditTitleViewController.h" @interface CYActiveTitleViewController () @property (nonatomic,copy) NSArray *rankArr; @property (nonatomic,copy) NSArray *nameArr; @end @implementation CYActiveTitleViewController - (void)viewDidLoad { [super viewDidLoad]; [g_notify addObserver:self selector:@selector(refresh:) name:kgroupLevelNameRefresh object:nil]; self.isGotoBack = YES; UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP+0.5, JX_SCREEN_WIDTH, .5)]; lineView2.backgroundColor = HEXCOLOR(0xdcdcdc); self.tableView.tableHeaderView = lineView2; self.title = @"活跃头衔"; self.heightHeader = JX_SCREEN_TOP; self.heightFooter = 0; self.isGotoBack = YES; self.isShowFooterPull = NO; self.isShowHeaderPull = NO; [self createHeadAndFoot]; // 获取头衔 // act_roomGetRoom [g_server roomGetRoom:_room.roomId toView:self]; } - (NSArray *)rankArr { if (_rankArr == nil) { _rankArr = @[@"LV6",@"LV5",@"LV4",@"LV3",@"LV2",@"LV1"]; } return _rankArr; } - (NSArray *)nameArr { if (_nameArr == nil) { // _nameArr = @[@"潜水",@"冒泡",@"吐槽",@"活跃",@"话痨",@"传说"]; _nameArr = @[@"传说",@"话痨",@"活跃",@"吐槽",@"冒泡",@"潜水"]; } return _nameArr; } - (void)didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1 { if ([aDownload.action isEqualToString:act_roomGetRoom]) { NSString *groupLevelName = [dict objectForKey:@"groupLevelName"]; NSArray *arr = [groupLevelName componentsSeparatedByString:@","]; // 数组翻转 _nameArr = [[arr reverseObjectEnumerator] allObjects]; _rankArr = @[@"LV6",@"LV5",@"LV4",@"LV3",@"LV2",@"LV1"]; [self.tableView reloadData]; } } - (void)refresh:(NSNotification *)note { [SVProgressHUD setMaximumDismissTimeInterval:2.0]; [SVProgressHUD showSuccessWithStatus:@"修改成功"]; NSArray *newArray = note.object; // 数组翻转 _nameArr = [[newArray reverseObjectEnumerator] allObjects]; _rankArr = @[@"LV6",@"LV5",@"LV4",@"LV3",@"LV2",@"LV1"]; [self.tableView reloadData]; } - (void)dealloc { [g_notify removeObserver:self]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.nameArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString * identifier = @"CYMusicTypeTableViewCell"; CYActiveTieleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (!cell) { cell = [[CYActiveTieleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; } cell.title.text = self.rankArr[indexPath.row]; cell.subtitleText = self.nameArr[indexPath.row]; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 40; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ CYEditTitleViewController *vc = [[CYEditTitleViewController alloc] init]; vc.room = self.room; vc.num = _nameArr.count - indexPath.row; vc.rankTitle = _nameArr[indexPath.row]; vc.nameArr = self.nameArr; [g_navigation pushViewController:vc animated:YES]; } @end