![](/img/trans.png)
[英]Objective-C: How to add thumbanils to a TableView From Videos?
[英]How to add a tableView into a CellView in objective c?
我想在一个单元格中显示一个tableView:
_____________________________________
| (IMAGE) ______________ | --CELL 0
| | MyCustomText|--CELL 0.0 |
| |_____________| |
| |MyCustomText2|--CELL 0.1 |
| |_____________| |
| |
| |
--------------------------------------
_____________________________________
| (IMAGE) 2 | --CELL 1
--------------------------------------
我正在尝试在情节提要中添加tableView,然后与新的TableviewController和新的CustomCellTableView连接,但这在行表中未显示任何内容。
这是可能的? 如何声明viewController或不需要添加ViewController?
谢谢!
我认为您不需要新的tableview控制器。 在表格单元格中,您可以添加另一个表格视图。
@interface ImageCell : UITableViewCell<UITableViewDataSource,UITableViewDelegate>
@property (retain, nonatomic) IBOutlet UITableView *abc;
@end
并照常实现数据源和委托方法。
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
// Configure the cell...
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (tableView == self.tableView) {
return 8;
} else {
return 3;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
if (tableView == self.tableView) {
cell = [self.tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
if (indexPath.row == 0) {
self.childTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, 100)];
self.childTableView.delegate = self;
self.childTableView.dataSource = self;
[cell.contentView addSubview:self.childTableView];
}else {
cell.textLabel.text = @"Pavan";
}
} else if (tableView == self.childTableView){
cell = [self.tableView dequeueReusableCellWithIdentifier:@"childCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"childCell"];
}
cell.textLabel.text = @"hi";
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == self.tableView) {
if (indexPath.row == 0) {
return 250;
} else {
return 100;
}
} else {
return 50;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.