我有关于如何将UIView添加到UITableViewCell的问题。关于如何将UIview作为子视图添加到UITableCell的问题
在我的学习项目我有一个UITableViewController(TableTestViewController,一个UITabelViewCell.xib(MainTabelCell.xib)和一个UIView(InnerTableView)。 我的目标IST显示在UITableView中的MainTableCell并在此MainTabelCell的InnerTabelView但我只是设法显示表中的单元格
TableTestViewController.h:
#import <UIKit/UIKit.h>
#import "InnerTableView.h"
@interface TableTestViewController : UITableViewController {
UITableView *mainTable;
UITableViewCell *nibLoadedCell;
InnerTableView *innerView;
}
@property(nonatomic, retain) IBOutlet UITableView *mainTable;
@property(nonatomic, retain) IBOutlet UITableViewCell *nibLoadedCell;
@property(nonatomic, retain) InnerTableView *innerView;
@end
TableTestViewController.m:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"MainTableCell"
owner:self options:NULL];
cell = nibLoadedCell;
}
// Configure the cell.
innerView = [[UIViewController alloc] init];
[cell addSubview: innerView.view];
return cell;
}
有没有人有想法为什么innerView不会显示在TabelViewCell中?我在这里错过了什么?我仍然在学习所有这些东西,但5个小时后,我没有在我的书籍中找到线索。希望这不是一个以愚蠢的问题:)
谢谢
CaptnCrash
确保插座配置正确。检查.xib,nib或故事板上文件的所有者属性 – 2016-09-18 23:56:13