0

I want to add one UITableView on which there are two types of Custom UITableViewCell. One of Cell should contain UITableView with other custom Cells H. This is how my code for of the UITableViewCell looks, on which I added another UITableView.

#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
Sanjay Mohnani
  • 5,947
  • 30
  • 46
Rohit_RK
  • 405
  • 4
  • 12
  • You should consider redesigning your structure. Using a UITableView inside another is not a good design. Alternatively, you could push another UITableViewController on the tap of the cell with the intended contents. – ZeMoon Mar 31 '15 at 05:26
  • 1
    Yes you can. I have done this many times. – atulkhatri Mar 31 '15 at 05:44

1 Answers1

1

Yes, you can add a UITableView on UITableViewCell -

For more info related to the same refer below link-

Is it possible to add UITableView within a UITableViewCell

Community
  • 1
  • 1
Sanjay Mohnani
  • 5,947
  • 30
  • 46