zoukankan      html  css  js  c++  java
  • IOS学习之路十六(UItableView 通过Prepare for segue 页面传值)

    当你点击一个UITableView 的section 或者cell的时候希望把值传到另一个页面(页面是通过segue跳转的),可以通过prepareforsegure 方法传值

    (我的UITableView Controller 添加了NavigationController)

    示例代码如下:

    - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        
        UIViewController *controller;
        if ([segue.destinationViewController isKindOfClass:[UINavigationController class]]) {
            UINavigationController *navController = (UINavigationController *)segue.destinationViewController;
            controller = [navController.viewControllers objectAtIndex:0];
        } else {
            controller = segue.destinationViewController;
        }
        
        if ([controller isKindOfClass:[NewsDetailViewController class]]) {
            NewsDetailViewController *detailController = (NewsDetailViewController *)controller;
            NSIndexPath *selectIndexPath = [self.mainTableView indexPathForSelectedRow];
            //[detailController setDataString:[NSString stringWithFormat:@"%i",selectIndexPath.section]];
            [detailController setDataString:[self.dataArray objectAtIndex:selectIndexPath.section]];
        } else {
            NSAssert(NO, @"Unknown segue. All segues must be handled.");
        }
        
    }

    原文出处:http://blog.csdn.net/wildcatlele



  • 相关阅读:
    数据结构 课程安排 (拓扑排序)
    数据结构 通畅工程 (最小生成树)
    01 C#基础
    计算机组成原理——第一章 系统概述
    数据结构——第八章 排序 第九章 文件
    数据结构——第七章 查找
    字符编码(转)
    数据结构——第六章 图
    NodeJS加密算法(转)
    入职总结
  • 原文地址:https://www.cnblogs.com/lixingle/p/3312963.html
Copyright © 2011-2022 走看看