2015-03-31 99 views
-1

我想添加一个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 
+0

你应该考虑重新设计结构。在另一个里面使用UITableView并不是一个好设计。或者,您可以在预期内容的单元上点击另一个UITableViewController。 – ZeMoon 2015-03-31 05:26:58

+1

是的,你可以。我做了很多次。 – atulkhatri 2015-03-31 05:44:21

回答