ios - 怎么传值到下一个控制器
ringa_lee
ringa_lee 2017-04-17 15:59:32
[iOS讨论组]
ringa_lee
ringa_lee

ringa_lee

全部回复(2)
高洛峰
// 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];
}

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号