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];

  • 相关阅读:
    HBase 列族数量为什么越少越好
    Hbase 认识及其作用
    Hbase 源码讲解
    Hbase 目录树
    rabbitmq 连接过程详解
    rabbit 兔子和兔子窝
    rabbit 函数参数详解
    rabbitmq 用户和授权
    火狐浏览器安装有道插件
    rabbitmq vhost
  • 原文地址:https://www.cnblogs.com/damnbird/p/4919837.html
Copyright © 2011-2022 走看看