Forum Archive

Converting UIView to _ui.View and viceversa

filippocld223

Hi,
Can someone tell me (if possible) how to convert an objcutil generated view(UIView) to a ui module version(_ui.View).

If not possible, how to present a UIView inside a sheet/popover/panel?

Thanks in advance
Filippo

JonB

You cannot convert from ObjC to ui, but you can add as a subview, by using the ObjCInstance of your ui parent view

import ui
from objc_util import *
objc_label=ObjCClass('UILabel').alloc().initWithFrame_(CGRect(CGPoint(0,0),CGSize(200,50))).autorelease()
objc_label.setText_('this is the objc label')

ui_view=ui.View(frame=(0,0,200,200))
ObjCInstance(ui_view).addSubview_(objc_label)
ui_view.present('popover')
filippocld223

It is good for my needs anyway :-)

Thank you very much :-)