Xcode
osx
首先,在tableViewController中设置好 代理和数据源方法:@interface eatTableViewController ()
实现一系列的数据源方法:让其显示数据 例如 简单显示 几行 11 如下:#pragma mark 数据源方法 /** * 一共有多少组数据 */-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 2 ;}/** * 第section组有多少行 */-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (section == 0) { return 2 ; }else{ return 4 ; }}-(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; cell.textLabel.text = @'11'; return cell ;}
重点在这里了。。。。添加此方法即可跳转了。-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ eatDetailVC *detailView = [[eatDetailVC alloc]init]; [self.navigationController pushViewController:detailView animated:NO];}注:点击cell 后先创建个UIview 之后再用navigationController 推送出来这样就可以成功通过点击cell 创建新页面了 实现跳转了。
注意数据源 和代理方法的实现
之前的页面一定要设置根控制器