What to do if you have a framework that provides a modal view controller for iPad to do some actions, but it only allows to be presented in portrait orientation, and your app supports landscape orientation only? It looked very weird when the user uses the app in landscape mode, clicks a button, and the view swipes from left, rotated 90 degrees clockwise. You have no source code to change that. In my case, there was no reason to limit the supported orientations of the framework’s controller, as it could easily fit in landscape-oriented screen.
The first thought that popped up in my head was to apply transformations to rotate the view. It’s a very hacky solution though, thus it can be used as a last resort.
Luckily, due to the dynamic nature of Objective-C, I managed to rotate the view with the help of the category:
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
And no need to create a child class. Instead just include the header with the category and you’re set.
A few notes here. First, I also hid the status bar (as the app doesn’t show it). Second, these amendments are applied on iPads only.