以下是两种解决方案:
第一种:
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
}
}
}
//从根控制器开始查找
UIViewController *rootVC = window.rootViewController
UIViewController *activityVC = nil
while ( true ) {
if ([rootVC isKindOfClass:[UINavigationController class]]) {
activityVC = [(UINavigationController *)rootVC visibleViewController]
} else if ([rootVC isKindOfClass:[UITabBarController class]]) {
activityVC = [(UITabBarController *)rootVC selectedViewController]
} else if (rootVC.presentedViewController) {
activityVC = rootVC.presentedViewController
} else {
break
}
rootVC = activityVC
}
return rootVC
第二种:
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
}
}
}
//从根控制器开始查找
UIViewController *rootVC = window.rootViewController
id nextResponder = [rootVC.view nextResponder]
NSLog(@"nextResponder---%@",nextResponder)
if ([nextResponder isKindOfClass:[UINavigationController class]]) {
result = ((UINavigationController*)nextResponder).topViewController
if ([result isKindOfClass:[UITabBarController class]]) {
result = ((UITabBarController *)result).selectedViewController
}
} else if ([nextResponder isKindOfClass:[UITabBarController class]]) {
result = ((UITabBarController*)nextResponder).selectedViewController
if ([result isKindOfClass:[UINavigationController class]]) {
result = ((UINavigationController *)result).topViewController
}
} else if ([nextResponder isKindOfClass:[UIViewController class]]) {
result = nextResponder
} else {
result = window.rootViewController
if ([result isKindOfClass:[UINavigationController class]]) {
result = ((UINavigationController *)result).topViewController
if ([result isKindOfClass:[UITabBarController class]]) {
result = ((UITabBarController *)result).selectedViewController
}
} else if ([result isKindOfClass:[UIViewController class]]) {
result = nextResponder
}
}
return result
推荐第二种。
在win8上不能安装VC6++,因为两者不兼容,出现如上图问题。VC6++起初是以面向XP的,在win7上可以以兼容模式+管理员模式安装并运行。
但是在更高版本的win8中,兼容模式也不能凑效了。
建议:在win8上,安装VC的高版本,如Microsoft Visual Stdio 2008/2010/2012/2013等,安装时勾选或只选择C/C++模块即可。2012/2013版可在官网下载,其他版本请百度。
记得采纳哦!!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)