生活随笔
收集整理的這篇文章主要介紹了
获取当前屏幕显示的viewcontroller
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
NavigationController -?(UIViewController?*)getCurrentVC??{??????UIViewController?*result?=?nil;????????????UIWindow?*?window?=?[[UIApplication?sharedApplication]?keyWindow];??????if?(window.windowLevel?!=?UIWindowLevelNormal)??????{??????????NSArray?*windows?=?[[UIApplication?sharedApplication]?windows];??????????for(UIWindow?*?tmpWin?in?windows)??????????{??????????????if?(tmpWin.windowLevel?==?UIWindowLevelNormal)??????????????{??????????????????window?=?tmpWin;??????????????????break;??????????????}??????????}??????}????????????UIView?*frontView?=?[[window?subviews]?objectAtIndex:0];??????id?nextResponder?=?[frontView?nextResponder];????????????if?([nextResponder?isKindOfClass:[UIViewController?class]])??????????result?=?nextResponder;??????else??????????result?=?window.rootViewController;????????????return?result;??} ?
轉載于:https://www.cnblogs.com/haohao-developer/p/5610659.html
總結
以上是生活随笔為你收集整理的获取当前屏幕显示的viewcontroller的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。