- 選用UIViewController or UITableViewController
UITableViewController局限性:它的view永遠(yuǎn)只屬于一個(gè)tableview
UITableViewController特性:會(huì)在第一次顯示tableview的時(shí)候加載數(shù)據(jù)于宙,支持下拉刷新倘要。
通過(guò)在UIViewController中使用UITableViewController,即將UITableViewController作為Child View Controller使用砌些。
如果他們之間需要建立消息通訊,可用delegate protocol來(lái)實(shí)現(xiàn)煞抬。
- (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的設(shè)計(jì)蚀同,用category進(jìn)行封裝
- 在cell內(nèi)部控制cell狀態(tài)(高亮癞谒,高度等屬性)即在自定義cell中設(shè)置這些屬性。