只有当I s>=8.0时,我如何才能启动以下方法?
它在TabBarController类中。
let floatVersion = (UIDevice.currentDevice().systemVersion as NSString).floatValue
func tabBarController(tabBarController: UITabBarController, animationControllerForTransitionFromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
// if ( floatVersion >= 8.0) {
let transitioningObject: TransitioningObject = TransitioningObject()
transitioningObject.tabBarController = self
return transitioningObject
//}
}
最佳答案
检查this response以验证系统版本。
您已经在正确的轨道上了,只需像处理if
一样处理iOS >= 8.0
,否则调用iOS7替代项并返回nil
let floatVersion = (UIDevice.currentDevice().systemVersion as NSString).floatValue
func tabBarController(tabBarController: UITabBarController, animationControllerForTransitionFromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
if ( floatVersion >= 8.0) {
let transitioningObject: TransitioningObject = TransitioningObject()
transitioningObject.tabBarController = self
return transitioningObject
}else {
//do something else here if it's iOS7 or earlier?
}
return nil
}