1

When the orientation changes, is it possible to execute a function and wait for it until it finish executing and then perform the rotation? Something like that:

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  

        })
    }
Mayank Patel
  • 3,868
  • 10
  • 36
  • 59
ella23
  • 53
  • 4

1 Answers1

0

Swift 3

func doStuff(check:(_ Check : Bool)->Void){

    check(true)
}

and inside viewWillTransitionToSize func :

doStuff { (myCheck) in
        if myCheck{

            // do something
        }
    }
Rob
  • 2,649
  • 3
  • 27
  • 34