代码UITableView点击cell跳转
2024-10-10 20:19:22
首先,在tableViewController中设置好 代理和数据源方法:
@interface FirstTableViewController ()<UITableViewDataSource,UITableViewDelegate>
- 实现一系列的数据源方法:让其显示数据 例如 简单显示 几行 :
#pragma mark 数据源方法 /** * 一共有多少组数据 */ -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return ; } /** * 第section组有多少行 */ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == ) { return ; }else{ return ; } } -(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; cell.textLabel.text = @""; return cell ; }
- 添加此方法实现跳转。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { SecondTableViewController *SVC = [[SecondTableViewController alloc]init]; [self.navigationController pushViewController:SVC animated:YES]; }
注:点击cell 后先创建个UIview 之后再用navigationController 推送出来
这样就可以成功通过点击cell 创建新页面了 实现跳转了。
---------摘自百度经验,有删改,感谢原著
最新文章
- Re 模块
- 你真的了解UIButton、UILabel 吗?
- Linux gnome
- Kalman滤波器原理和实现
- UVa 3487 &; 蜜汁建图
- 协同过滤 CF &; ALS 及在Spark上的实现
- 转】MyEclipse使用总结——设置MyEclipse开发项目时使用的JDK
- String 内在分配解析
- echars3.0 柱状图大小设置
- swing容器继承重绘问题解决
- Tribles(概率)
- svn出现“Previous operation has not finished; run &#39;cleanup&#39; if it was interrupted”,解决方法
- UVA 1610 Party Games
- esb和eai的区别
- REST(Representational state transfer)的四个级别以及HATEOAS介绍
- 高通平台如何使用QPST抓DUMP
- fastcgi协议分析与实例
- CF1110D Jongmah(DP)
- Tensorflow图像处理
- R语言文件相关的操作