T. Benjamin Larsen
T. Benjamin Larsen

Reputation: 6393

Setting the explicit screenOrientation on a UIViewController for testing purposes

I'm writing a test on a UIViewController. The test has the purpose of testing a state that is only triggered when the device is in portrait mode. Is there a (relatively) simple way to set the "orientation" to portrait to make sure the required code-calls are made?

Upvotes: 0

Views: 96

Answers (1)

kovpas
kovpas

Reputation: 9593

There are two private UIApplication methods: rotateIfNeeded: and rotateIfNeeded:completion: which you can use during testing.

Make sure to wrap invocations with #ifdef statement, so they don't go into distribution build.

Upvotes: 1

Related Questions