//获取当前屏幕显示的viewcontroller
- (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;
}
获取当前屏幕显示的viewcontroller
原创mb62cf8bca18558 ©著作权
©著作权归作者所有:来自51CTO博客作者mb62cf8bca18558的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:修改webView的背景色
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章