Tried with this NY monkeypatching instead of swizzle because it is an instance method, not a class method. The def is called but no orientation change, and even no full screen.
Of course, it is not the main view controller. Sure, help will be needed.
from objc_util import *
import ui
def preferredInterfaceOrientationForPresentation(_self):#, _sel):
self = ObjCInstance(_self) # UIViewController
print('preferredInterfaceOrientationForPresentation:',self)
return 3 # UIInterfaceOrientationLandscapeLeft
@on_main_thread
def main():
UIViewController = ObjCClass('UIViewController')
vc = UIViewController.alloc().init()
# monkeypatch of UIViewController class instance method
UIViewController.preferredInterfaceOrientationForPresentation = preferredInterfaceOrientationForPresentation(vc)
vc.setModalPresentationStyle_(2) # full screen
l = ui.Label()
l.frame = (10,10,100,32)
l.text = 'label'
vc.view().addSubview_(ObjCInstance(l))
rootvc = UIApplication.sharedApplication().keyWindow().rootViewController()
rootvc.presentViewController_animated_completion_(vc, True, None)
if __name__ == '__main__':
main()