在一个tableViewCell中有个btn,如何得到它所在的viewcontroller,以便于push出新的viewController?

我的思路是传值,但网上有下面这种方法,分享。

跟得到某个视图上的子视图思想类似,但之前没有接触过 UIResponder,所以没有想到。

- (UIViewController *)viewController {
for (UIView* next = [self superview]; next; next =
next.superview) {
UIResponder* nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {return (UIViewController*)nextResponder;
}
}
return nil;
}

最新文章

  1. 解析大型.NET ERP系统 查找与钻取
  2. Dynamics AX 2012 R2 通过数据源保存记录时触发的方法
  3. Delphi指针的用法
  4. GET和POST的主要区别
  5. C# - openxml 操作excel - '“System.IO.Packaging.Package”在未被引用的程序集中定义'
  6. ubuntu14.04 Markdown编辑器推荐之Remarkable
  7. 51nod 1686 第k大区间
  8. SLAM+语音机器人DIY系列:(一)Linux基础——3.Linux命令行基础操作
  9. javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
  10. Nginx、haproxy反向代理设置
  11. 详解 ESLint 规则,规范你的代码
  12. ASP.NET匿名对象与集合的使用
  13. C++中cin的用法汇总
  14. C语言学生管理系统源码分享
  15. git命令上传项目到码云总结
  16. python 输出所有列表元素的乘积
  17. GitHub Permission to <<repository>> denied to <<username>>
  18. java.util.concurrent.Semaphore 使用
  19. 当集合里存储的是URL时的一些问题总结
  20. BNU 20860——Forwarding Emails——————【强连通图缩点+记忆化搜索】

热门文章

  1. 给出2n+1个数,其中有2n个数出现过两次,如何用最简便的方法找出里面只出现了一次的那个数(转载)
  2. javascript 常用array类型方法
  3. How to scroll the window using JQuery $.scrollTo() function
  4. window 7 C盘整理
  5. VBox UUID already exists 问题处理
  6. 原创 HTML5:JS操作SVG实践体会
  7. select options常用操作
  8. [Python笔记]第二篇:运算符、基本数据类型
  9. Python三元表达式
  10. asp.net(C#)写SQL语句技巧