获取当前最顶层的VC
#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的更多相关文章
- iOS学习——获取当前最顶层的ViewController
在iOS开发过程中,我们经常性会需要获取当前页面的ViewController,然后利用ViewController进行一些操作,例如在最顶层的ViewController上展示一个UIAlertCo ...
- 获取当前最顶层的ViewController
- (UIViewController *)topViewController { UIViewController *resultVC; resultVC = [self _topViewContr ...
- 获取本地IP地址的vc代码
作者:朱金灿 来源:http://blog.csdn.net/clever101 获取本地IP地址有两种做法.一种是使用gethostname函数,代码如下: bool CSocketComm::Ge ...
- IOS 获取当前对象所在的VC
id next = [self nextResponder] ; while (next != nil) { next = [next nextResponder]; if ([next isKind ...
- iOS-Runtime之关于页面跳转的捷径【Runtime获取当前ViewController】
写在前面 在我们操作页面跳转时,如果当前的类不是UIViewcontroller(下面用VC表示),你会不会写一个代理,或者block给VC传递信息,然后在VC里面进行 ///假如targetVc是将 ...
- iOS(Swift)-Runtime之关于页面跳转的捷径【Runtime获取当前ViewController,很常用】
写在前面 在我们操作页面跳转时,如果当前的类不是UIViewcontroller(下面用VC表示),你会不会写一个代理,或者block给VC传递信息,然后在VC里面进行 ///假如targetVc是将 ...
- 故事板(Storyboard) 、 iPad编程 、 App和VC的生命周期
1 创建动态TableView 1.1 问题 动态表视图就是显示多少分区,多少行以及每一行的显示内容都是根据数据源来决定.之前我们学过用xib展示动态表视图,本案例将学习如何使用Storyboard展 ...
- autolayout之后获取uiview的frame
这个只要一行代码就搞定了.详细请看: In order to get the right frame/bounds of your UIImageView after resizing, you ne ...
- SQL语句执行与结果集的获取
title: SQL语句执行与结果集的获取 tags: [OLEDB, 数据库编程, VC++, 数据库] date: 2018-01-28 09:22:10 categories: windows ...
随机推荐
- java异常——Exception、RuntimException
一.Exception和RuntimeException的区别 Exception是RuntimeException的父类,使用了 Exception 的类都必须对异常进行处理(try / throw ...
- C++使用指针的优点
使用指针可以带来如下的好处: (1)可以提高程序的编译效率和执行速度,使程序更加简洁. (2)通过指针被调用函数可以向调用函数处返回除正常的返回值之外的其他数据,从而实现两者间的双向通信. (3)利用 ...
- 12Linux_Apache_vsftpd(匿名开发模式)
网站:让我们的用户可以通过浏览器去访问到的文档的资源. windows:IIS Linux:Apache Nginx(吃得少,干的多) APACHE:基金会,公司,软件 httpd:软件名称,软件包名 ...
- Python module ---- abc
python中并没有提供抽象类与抽象方法,但是提供了内置模块abc(abstract base class)来模拟实现抽象类. ABC,Abstract Base Class(抽象基类),主要定义了 ...
- sql语句应用
laravel5.6框架中用到的sql语句 //排序 $data=DB::table('admin')->select(array('id','name','password'))->or ...
- node读取文件转换json文件
{ ".323":"text/h323" , ".3gp":"video/3gpp" , ".aab" ...
- html:布局class名和其他class名个人整理总结
一:app 二:header 三:main 四:footer 1:中横杠:布局(main-top.main-left等) 2:下横杠:状态(item-active:选中等)
- Redis广播
参见:http://blog.csdn.net/u011734144/article/details/51782085
- LevelDB源码分析-Write
Write LevelDB提供了write和put两个接口进行插入操作,但是put实际上是调用write实现的,所以我在这里只分析write函数: Status DBImpl::Write(const ...
- CSS3奇特的渐变示例
渐变 4个维度去理解渐变 线性渐变 径向渐变 新写法 老写法 最后的老写法镜像渐变可能不太准确.其余都完全正确 <!DOCTYPE html> <html> <head& ...