Skip to content

Instantly share code, notes, and snippets.

@cvpe
Created May 14, 2020
Embed
What would you like to do?
a.py
from objc_util import *
import ui
def preferredInterfaceOrientationForPresentation(_self,_cmd):
#self = ObjCInstance(_self) # UIViewController
#print('preferredInterfaceOrientationForPresentation:',self)
return 3 # UIInterfaceOrientationLandscapeLeft
@on_main_thread
def main():
UIViewController = ObjCClass('UIViewController')
MyUIViewController = create_objc_class('vc', superclass=UIViewController, methods=[preferredInterfaceOrientationForPresentation])
vc = MyUIViewController.alloc().init()
print(dir(vc))
vc.setModalPresentationStyle_(0)
v = ui.View()
v.frame = (10,10,600,500)
v.background_color = 'white'
b = ui.Button()
b.frame = (10,10,32,32)
b.title = 'x'
def bclose(sender):
v.close()
b.action = bclose
v.add_subview(b)
vc.view().addSubview_(ObjCInstance(v))
rootvc = UIApplication.sharedApplication().keyWindow().rootViewController()
rootvc.presentViewController_animated_completion_(vc, True, None)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment