扫码关注官方订阅号
ringa_lee
// controller a @interface ControllerA : UIViewController { // 你的文章列表 @property(nonatomic, strong)NSMutableArray *list; } @implementation ControllerA { // 文章点击时候 传index给事件 -(void)btnClick:(int)index { ControllerB *cb = [[ControllerB alloc]init]; // 这样传值就行了 cb.index = index; } } // controller b @interface ControllerB : UIViewController { // 用属性存储值 @property(nonatomic, copy) NSString * _id; } @implementation ControllerA { // viewdidload中根据index加载内容 }
你可以在didSelect方法中获取到当前点击的cell,然后把cell的属性赋给DetailController的属性
(void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath{NSLog(@"选中cell");UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
DetailViewController *detailViewController = [[DetailViewController alloc] init];detailViewController.xxxproperty = cell.xxxxx;[self.navigationController pushViewController:detailViewController animated:YES];}
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
你可以在didSelect方法中获取到当前点击的cell,然后把cell的属性赋给DetailController的属性
(void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath{
NSLog(@"选中cell");
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
DetailViewController *detailViewController = [[DetailViewController alloc] init];
detailViewController.xxxproperty = cell.xxxxx;
[self.navigationController pushViewController:detailViewController animated:YES];
}