- 选用UIViewController or UITableViewController
UITableViewController局限性:它的view永远只属于一个tableview
UITableViewController特性:会在第一次显示tableview的时候加载数据,支持下拉刷新。
通过在UIViewController中使用UITableViewController,即将UITableViewController作为Child View Controller使用。
如果他们之间需要建立消息通讯,可用delegate protocol来实现。
- (void)addTalkingDetailViewController{
TalkingDetailController *talkingDetailController = [[TalkingDetailController alloc] init];
talkingDetailController.delegate = self;
talkingDetailController.talings = @[@"hi!",@"Hello!",@"Nice to meet you",@"me too", @"are you ok", @"I'am fine", @"burden ", @"come on"];
[self addChildViewController:talkingDetailController];
CGRect frame = self.view.bounds;
frame.origin.y = 100;
// frame.size.height = frame.size.height - 200;
talkingDetailController.view.frame = frame;
[self.view addSubview:talkingDetailController.view];
[talkingDetailController didMoveToParentViewController:self];
}
#pragma mark - talking delegate
- (void)tableView:(UITableView *)tableView didselectRow:(NSIndexPath *)indexPath
{
DetailController *detail = [[DetailController alloc] init];
CGRect frame = self.view.bounds;
detail.view.frame = frame;
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
detail.label = cell.textLabel.text;
[self.navigationController pushViewController:detail animated:YES];
}
- 不要暴露cell的设计,用category进行封装
- 在cell内部控制cell状态(高亮,高度等属性)即在自定义cell中设置这些属性。