我正在尝试像树视图一样使用表视图来选择多个项目 您还知道其他方法来做树状视图吗?
我正在尝试向不同提供商的相机用户授予权限
如何从标题部分的UIButton中选择所有子级
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
CGRect frame = tableView.frame;
UIButton *selectButton = [[UIButton alloc] initWithFrame:CGRectMake(0,-5,40,40)];
[selectButton setImage:[UIImage imageNamed:@"ic_combobox_off"] forState:UIControlStateNormal];
[selectButton addTarget:self action:@selector(headerSelected:) forControlEvents:UIControlEventTouchUpInside];
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(40,200,30)];
title.text = [_dataProviders objectAtIndex:section];
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0,frame.size.width,frame.size.height)];
[headerView addSubview:selectButton];
[headerView addSubview:title];
[headerView setBackgroundColor:UIColor.lightGrayColor];
return headerView;
}
- (void) headerSelected:(NSInteger) section { }
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
VideoPermissionsServicetableViewCell *cell = (VideoPermissionsServicetableViewCell*) [tableView dequeueReusableCellWithIdentifier:CELL_VIDEO_PERMITION forIndexPath:indexPath];
NSString *sectionTitle = [_dataProviders objectAtIndex:indexPath.section];
NSArray *sectionDevice = [_dataInput objectForKey:sectionTitle];
NSString *device = [sectionDevice objectAtIndex:indexPath.row];
cell.deviceLabel.text = device;
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
return cell;
}
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSString *providers = [_dataProviders objectAtIndex:section];
NSArray *devices= [_dataInput objectForKey:providers];
return [devices count];
}