Я хочу добавить один UITableView
, на котором есть два типа пользовательских UITableViewCell
. Один из ячеек должен содержать UITableView
с другими пользовательскими ячейками H. Вот как выглядит мой код для UITableViewCell
, на который я добавил еще UITableView
.Можно ли добавить UITableView в пользовательский UITableViewcell?
#import "MainDetailsCell.h"
#import "SubCell.h"
static NSString * const SubCellIdentifier = @"SubCell";
@implementation MainDetailsCell
- (void)awakeFromNib {
// Initialization code
[_DetailsTable registerNib:[UINib nibWithNibName:SubCellIdentifier bundle:[NSBundle mainBundle]] forCellReuseIdentifier:SubCellIdentifier];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
#pragma mark -tableview Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 4;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *retCell;
SubCell *cell = [_DetailsTable dequeueReusableCellWithIdentifier:LocationDetailsCellIdentifier forIndexPath:indexPath];
retCell=cell;
[retCell setSelectionStyle:UITableViewCellSelectionStyleNone];
return retCell;
}
@end
Вы должны рассмотреть вопрос реорганизации своей структуры. Использование UITableView внутри другого не является хорошим дизайном. В качестве альтернативы вы можете нажать другой UITableViewController на кране ячейки с предполагаемым содержимым. – ZeMoon
Да, вы можете. Я делал это много раз. – atulkhatri