Skip to content

Instantly share code, notes, and snippets.

@cvpe
Created May 14, 2020 16:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cvpe/bd9af8c4ed19c4f0ec8fa964f025d69e to your computer and use it in GitHub Desktop.
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