Search code examples
objective-cios6xcode4.5ios-ui-automation

Wait while screen rotates


I wish to put a wait until the iPad screen is done rotating and want to have both rotate and wait in the same function. If I don't add few seconds of wait, then the app doesn't behave as expected. Below is the function:

LandScapeRight = function() 
{
   return UIATarget.localTarget().setDeviceOrientation(UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT);
}

Please suggest.


Solution

  • You want to use the delay() method on UIATarget. The docs for the class are here

    The quick and dirty way to do the delay you want is like so:

    LandScapeRight = function() 
    {
       var target = UIATarget.localTarget();
       target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT);
       target.delay(1);   // Delay is in seconds, can be a fraction
    }