iOS Question Rootpanel from a CustomView

D

Deleted member 103

Guest
Hi,

I have to find the Rootpanel from my own CustomView.

This is my solution that works in my case.
The question is whether it works everywhere and if not, if there may be a better solution?


B4X:
Public Sub DesignerCreateView (Base As Panel, lbl As Label, Props As Map)
    mBase.Value = Base
    ...
    myRootPanel = getRootPanel(Base)
    
    myRootPanel.AddView(pnlBackground, 0, 0, myRootPanel.Width, myRootPanel.Height)
    ...
End Sub

Private Sub getRootPanel(Base As Panel) As View
    Dim v As View = Base.Parent
    Do While v.Width > 0
        v = v.Parent
    Loop
    Return v
End Sub
 
D

Deleted member 103

Guest
Unfortunately, it is not that easy, or I do not know how it should work.
Here is the error message:

Application_Start
Error occurred on line: 87 (ComboBox2)
Expected: UIViewController, object type: B4IPanelView
Stack Trace: (
CoreFoundation <redacted> + 252
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation <redacted> + 0
B4i-CustomViews -[B4IObjectWrapper setObject:] + 280
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 292
B4i-CustomViews +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
B4i-CustomViews -[B4IShell runVoidMethod] + 232
B4i-CustomViews -[B4IShell raiseEventImpl:method:args::] + 1800
B4i-CustomViews -[B4IShellBI raiseEvent:event:params:] + 1580
B4i-CustomViews -[B4ICustomViewWrapper AfterDesignerScript] + 1828
B4i-CustomViews -[B4ILayoutBuilder loadLayout:::] + 2892
B4i-CustomViews -[B4IPanelWrapper LoadLayout::] + 204
B4i-CustomViews -[b4i_main _application_start:] + 1520
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 292
B4i-CustomViews +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
B4i-CustomViews -[B4IShell runMethod:] + 448
B4i-CustomViews -[B4IShell raiseEventImpl:method:args::] + 2172
B4i-CustomViews -[B4IShellBI raiseEvent:event:params:] + 1580
B4i-CustomViews __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
libdispatch.dylib <redacted> + 24
libdispatch.dylib <redacted> + 16
libdispatch.dylib <redacted> + 1068
CoreFoundation <redacted> + 12
CoreFoundation <redacted> + 1924
CoreFoundation CFRunLoopRunSpecific + 436
GraphicsServices GSEventRunModal + 104
UIKitCore UIApplicationMain + 212
B4i-CustomViews main + 124
libdyld.dylib <redacted> + 4
)
 
Upvote 0
Top