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

  • 相关阅读:
    面向对象七大设计原则
    S2第六章
    S2第四章
    大数据Hadoop——HDFS Shell操作
    大数据Hadoop——初识Hadoop
    ssh整合oracle数据源报错????
    关于Struts2的通配方法、转发重定向
    SSH实现ajax
    关于Struts2自动装配和访问Servlet API
    Oracle函数
  • 原文地址:https://www.cnblogs.com/damnbird/p/4919837.html
Copyright © 2020-2023  润新知