The problem I'm trying to solve is this:
When using UIImagePicker, it is configured when the device rotates. I do not want this to be done, but should always remain in portrait orientation. I googled a lot and did not find any solution (just others with the same unsolved problem). The only answer was to use a private API request, I would not risk doing this.
-
However, I came across a โ swizzling method โ - a way to exchange method names at runtime. What I plan to do:
Add a category to the UIViewController that defines methods, such as customShouldRotate, that define custom behavior that will not allow rotation.
Prompt these methods with the default rotation methods for the UIViewController at runtime.
-
After a little thought, perhaps this is not so simple. That is why - any answers to the following would be greatly appreciated.
The method that I run is in the UIViewController, not the UIImagePickerController. I canโt select on the image collector myself, I have already tried through a subclass and it looks like this is a spy controller that handles the rotation, and not the UIImagePickerController itself. Will swizzled methods go to subclasses, if not, is there a workaround for this?
This cannot be the usual rotation method from the UIViewController that is used in the UIImagePickerController. Is there any way to tell?
Will Apple be ok with swizzling? I do not use a private API call, but then I would not be too surprised if they refused anyway.
-
Whether the whole idea is acceptable / worth a try - or if someone really solved the original problem differently, it will be even better.
source share