最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
IOS 下获取 rootviewcontroller 的版本不同的问题解决办法
时间:2022-06-25 23:14:34 编辑:袖梨 来源:一聚教程网
IOS 下获取 rootviewcontroller 的版本不同的问题解决办法
一般 原生的
[[UIApplication sharedApplication].keyWindow.rootViewController presentModalViewController:self animated:NO];
可以 获取 系统的 rootviewcontroller
但 cocos2d-x 2.1.1 在 appcontroller.mm 内定义的 加载方法是
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:viewController];
}
也就是说 只有在 ios6 下 才设置rootview 其他时候是 使用addsubview的方法 加载。
所以 相应的 获取 rootviewcontroller方法 要改为。
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
NSArray* array=[[UIApplication sharedApplication]windows];
UIWindow* win=[array objectAtIndex:0];
UIView* ui=[[win subviews] objectAtIndex:0];
UIViewController* ctrol=(UIViewController*)[ui nextResponder];
}
else
{
// use this method on ios6
UIViewController* ctrol=[UIApplication sharedApplication].keyWindow.rootViewController];
}
相关文章
- picacg哔咔网页版入口-嗶咔picacg在线高清观看 03-03
- twitter网页版-twitter官网入口 03-03
- 网易云游戏网页版一键直达-网易云游戏网页版即点即玩 03-03
- 樱花漫画正版入口分享:全彩无删减漫画高清画质不卡顿 03-03
- 歪歪漫画-最新漫画网入口首页 03-03
- jm漫画网页版-最新官方入口是什么 03-03