如果是问“是否可以在iPad上用VC开发程序”,那么肯定不可以,VC(VC6/VS2005/VS2008)只能运行在X86/WINDOWS平台上,无法在IOS(iPAD)上运行。
更新到13.5后,发现获取当前vc时,获取到的竟然是window。
以下是两种解决方案:
第一种:
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
推荐第二种。
apple在商店下载vc1.打开苹果设备,找到appstore图标,点击进入。
2.进入appstore后,会看到下方有一个搜索菜单。
3.在搜索框输入该软件,并点击输入法右下角的搜索键。
4.于是就搜索出该软件,点击获取按钮,会显示免费,点击下载。
5.待下载安装完成后,即可回到界面发现有了该软件图标。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)