跳到主要内容

群管理页面

提示

此功能在 5.12.2 版本开始支持。

群管理页面类是 RCGroupManagementViewController

提示

只有群主或者管理员才会在群设置页显示群管理项。

群管理权限只有群主可以显示和操作。

初始化

调用 RCGroupManagementViewController 类的初始化方法构建群管理页面。 注意,您需要创建一个 RCGroupManagementViewModel 对象, 作为 RCGroupManagementViewController 的业务逻辑处理模块。

参数说明

RCGroupManagementViewController 说明:

参数类型说明
viewModelRCGroupManagementViewModelRCGroupManagementViewController 的业务逻辑处理。

RCGroupManagementViewModel 说明:

参数类型说明
groupIdNSString群组 id

示例代码

Objective C
NSString *groupId = @"群组 Id";
RCGroupManagementViewModel *viewModel = [RCGroupManagementViewModel viewModelWithGroupId:groupId];
RCGroupManagementViewController *vc = [[RCGroupManagementViewController alloc] initWithViewModel:viewModel];
[viewController.navigationController pushViewController:vc animated:YES];

自定义群管理页面 cell

群管理页面的数据源是 RCBaseCellViewModel, 开发者自定义CellViewModel 可参考当前用户资料页自定义 cell 1、2 部分逻辑, 注意自定义 CellViewModel 改为继承RCBaseCellViewModel

自定义 CellViewModel 后,参考下面示例继续进行自定义操作:

1. 添加 RCGroupManagementViewModel 代理

Objective C
NSString *groupId = @"群组 Id";
RCGroupManagementViewModel *viewModel = [RCGroupManagementViewModel viewModelWithGroupId:groupId];
/// 设置代理
viewModel.delegate = self;

2. 修改数据源

Objective C
- (NSArray <NSArray <RCBaseCellViewModel *> *> *)groupManagement:(RCGroupManagementViewModel *)viewModel
willLoadItemsInDataSource:(NSArray <NSArray <RCBaseCellViewModel *> *> *)dataSource {
NSMutableArray *list = dataSource.mutableCopy;
RCProfileCustomCellViewModel *customCellVM = [RCProfileCustomCellViewModel new];
customCellVM.title = @"群管理自定义功能";
customCellVM.detail = @"默认值";
[list addObject:@[customCellVM]];
return list;
}

3.自定义 cell 点击事件

群管理页面的 cell 点击事件已经实现,开发者可以自定义拦截处理:

Objective C
- (BOOL)groupManagement:(RCGroupManagementViewModel *)viewModel
viewController:(UIViewController*)viewController
tableView:(UITableView *)tableView
didSelectRow:(NSIndexPath *)indexPath
cellViewModel:(RCBaseCellViewModel *)cellViewModel {

return YES;///YES : SDK 不再处理, NO: SDK 内部处理
}