I've been facing the following issue in the simulator since Xcode 9 -
The simulator does not refresh the layout on its screen in the completion block of UIView.animate() function calls. Consider the following code
let myView = UIView(frame: CGRect(x: 80.0, y: 80.0, width: 100.0, height: 100.0))
myView.isHidden = true
func presentNewScreen() {
UIView.animate(withDuration: 0.5, animations: {
//animate properties of some views in the current hierarchy ... works fine
}, completion: {(hasFinished:Bool) in
myView.isHidden = false
//the screen does not seem to refresh itself at this point ... so myView does not show up on the simulator screen
})
}
As indicated in the above snippet - even though the completion block is executed, myView does not show up on the Simulator Screen. Some points to note:
1) I logged a message inside the completion block so I can confirm that the completion block is indeed being called correctly
2) If I perform some action on the screen - eg click any other visible button or control element, the screen refresh is triggered and myView becomes visible
3) In case myView is a UIButton, even though it may not be visible, if I click on the region where its supposed to be located, the corresponding button action function is executed correctly
4) This has been happening since XCode 9, on ALL simulators running iOS 11.x as well as iOS 10.x
5) This DOES NOT happen on an actual device. The code works perfectly on any physical device
I am using a Macbook Pro 13" (Early 2011) running High Sierra, and using XCode 9.2. I read on another thread that there are some simulator issues on older machines with Intel HD 3000 Graphics configuration - https://forums.developer.apple.com/thread/88446
However the workaround suggested in the above thread doesnt work for me.
This is proving to be a real problem since I need the simulators to see and test my UI layouts on different device configurations. Any help will be greatly appreciated.
Thanks,