当方向改变时,是否可以执行一个功能并等待它直到完成执行然后执行旋转?这样的事情:
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
doStuff()
// block until doStuff is done
weak var weakSelf = self
coordinator.animateAlongsideTransition({ (UIViewControllerTransitionCoordinatorContext) -> Void in
}, completion: { (UIViewControllerTransitionCoordinatorContext) -> Void in
})
}
答案 0 :(得分:0)
Swift 3
func doStuff(check:(_ Check : Bool)->Void){
check(true)
}
和viewWillTransitionToSize
内部func:
doStuff { (myCheck) in
if myCheck{
// do something
}
}