I am using a subclass of UIScrollView, with another class being its UIScrollViewDelegate. This other class has a custom scrollViewDidZoom() func, which takes a bit of time to execute.
In another function, I want to calculate and set up a specific zoom scale for my UIScrollView and then do other code for the view inside. The problem is – the code after setting the zoom scale seems to execute before scrollViewDidZoom() finished running and took effect. To clarify, I want to do this:
@objc func myFunc(){
let wantedZoomScale = calcNewZoom()
myScrollView.setZoomScale(wantedZoomScale, animated: false)
// here I want to wait for scrollViewDidZoom() to finish running
// then execute the next line
doTheThingINeedNewScaleFor()
}
How can I ensure that?
myFunc() and scrollViewDidZoom() can be in one class, if it helps.




