#pragma mark -  获取当前最顶层的ViewController

- (UIViewController*)topVC:(UIViewController*)VC {

if([VC isKindOfClass:[UINavigationControllerclass]]) {

return[selftopVC:[(UINavigationController*)VC topViewController]];

}

if([VC isKindOfClass:[UITabBarControllerclass]]) {

return[selftopVC:[(UITabBarController*)VC selectedViewController]];

}

returnVC;

}

- (UIViewController*)topViewController {

UIViewController*vc = [selftopVC:[UIApplicationsharedApplication].keyWindow.rootViewController];

while(vc.presentedViewController) {

vc = [selftopVC:vc];

}

returnvc;

}

获取当前最顶层的VC的更多相关文章

  1. iOS学习——获取当前最顶层的ViewController

    在iOS开发过程中,我们经常性会需要获取当前页面的ViewController,然后利用ViewController进行一些操作,例如在最顶层的ViewController上展示一个UIAlertCo ...

  2. 获取当前最顶层的ViewController

    - (UIViewController *)topViewController { UIViewController *resultVC; resultVC = [self _topViewContr ...

  3. 获取本地IP地址的vc代码

    作者:朱金灿 来源:http://blog.csdn.net/clever101 获取本地IP地址有两种做法.一种是使用gethostname函数,代码如下: bool CSocketComm::Ge ...

  4. IOS 获取当前对象所在的VC

    id next = [self nextResponder] ; while (next != nil) { next = [next nextResponder]; if ([next isKind ...

  5. iOS-Runtime之关于页面跳转的捷径【Runtime获取当前ViewController】

    写在前面 在我们操作页面跳转时,如果当前的类不是UIViewcontroller(下面用VC表示),你会不会写一个代理,或者block给VC传递信息,然后在VC里面进行 ///假如targetVc是将 ...

  6. iOS(Swift)-Runtime之关于页面跳转的捷径【Runtime获取当前ViewController,很常用】

    写在前面 在我们操作页面跳转时,如果当前的类不是UIViewcontroller(下面用VC表示),你会不会写一个代理,或者block给VC传递信息,然后在VC里面进行 ///假如targetVc是将 ...

  7. 故事板(Storyboard) 、 iPad编程 、 App和VC的生命周期

    1 创建动态TableView 1.1 问题 动态表视图就是显示多少分区,多少行以及每一行的显示内容都是根据数据源来决定.之前我们学过用xib展示动态表视图,本案例将学习如何使用Storyboard展 ...

  8. autolayout之后获取uiview的frame

    这个只要一行代码就搞定了.详细请看: In order to get the right frame/bounds of your UIImageView after resizing, you ne ...

  9. SQL语句执行与结果集的获取

    title: SQL语句执行与结果集的获取 tags: [OLEDB, 数据库编程, VC++, 数据库] date: 2018-01-28 09:22:10 categories: windows ...

随机推荐

  1. django之关联field 描述子是如何实现的

    model定义时,每个field都是一个类属性,一个对象.在生成类时,属性有contribute_to_class的方法,会调用该方法. m2m field,它会先调用自己的contribute_to ...

  2. python大法好——飞机大战

    import pygame from pygame.locals import * import time def key_control(hero_temp): # 获取事件,比如按键等 for e ...

  3. 3sum 求三数之和等于0,不允许重复

    https://leetcode.com/problems/3sum/ 套路比较常见了,最重要的是去重.还是没法一次通过. class Solution { public: vector<vec ...

  4. List 去重

    private static List removeDuplicate(List list) { HashSet h = new HashSet(list); list.clear(); list.a ...

  5. nginx优化php-fpm优化 压力测试达到每分150万访问量webbench网站压力

    webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好,安装使用也特别方便. 1.适用系统:Linux 2.编译安装:引用wget http: ...

  6. makefile(一)

    Makefile的一个具体的实例 来源:http://blog.sina.com.cn/s/blog_73d4d5fa0100paiy.html (2011-03-06 23:10:02) 转载▼ 标 ...

  7. Windows下pip 离线包安装

    pip在线安装十分方便,有时候某些服务器并没有直接联网,需要下载好安装包上传到服务器上进行安装,不经常用,还是有点小麻烦的. 安装Python之后,将下载好的安装包包放在Python安装的根目录下使用 ...

  8. Java中获取系统时间的四种方式

    第一种: Date day=new Date(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" ...

  9. 【原创】qlogic网卡软中断不均衡问题分析

    引子 使用qlogic QL45000网卡测试业务性能,发现cpu软中断分布不均衡,而且很有规律,导致cpu空闲也不是很均衡, 会影响业务稳定性. 设备使用3张网卡Qlogic网卡,配置为4*25G模 ...

  10. MFC列表控件更改一行的字体颜色

    参考自(http://blog.csdn.net/ribut9225/article/details/6720639) 1.首先从CListCtrl 继承一个类,命名为CListCtrlCl 在头文件 ...