zoukankan      html  css  js  c++  java
  • ios 自定义cell类中获取当前controller push

    有时候在自定义cell的过程中,当cell中又button的时候,把button的点击时间写在cell中的时候,需要获取到cell的父视图控制器然后push,可以自建一个类,命名为:

    GetCurrentNaviGationController,在.h文件 中提供一个类方法

    +(UIViewController *)viewController:(UIView *)view;

     

    然后在.m中实现

    +(UIViewController *)viewController:(UIView *)view{

        /// Finds the view's view controller.

        // Traverse responder chain. Return first found view controller, which will be the view's view controller.

        UIResponder *responder = view;

        while ((responder = [responder nextResponder]))

            if ([responder isKindOfClass: [UIViewController class]])

                return (UIViewController *)responder;

        // If the view controller isn't found, return nil.

        return nil;

    }

     

    然后在想调用的cell中引入头文件,然后调用

    [[GetCurrentNaviGationController viewController:self].navigationController pushViewController:controller animated:YES];

  • 相关阅读:
    html中嵌入天气预报
    linux简单命令
    正则表达式基本语法
    jquery表单验证
    yaf函数方法及使用
    php函数
    yaf框架的特点
    mysql数据库
    php连数据库
    xml基础知识
  • 原文地址:https://www.cnblogs.com/damnbird/p/4919837.html
Copyright © 2011-2022 走看看