iOS Question B4XPage - how to set a pages presentViewController

Alexander Stolte

Expert
Licensed User
Longtime User
if i try this code on B4XPage_Created:
B4X:
PresentPage2(B4XPages.GetNativeParent(B4XPages.MainPage),B4XPages.GetNativeParent(Me))
B4X:
Sub PresentPage2(Parent As Page, dialog As Page)
    Dim no As NativeObject = dialog
    no.SetField("modalTransitionStyle",0)

    Dim no2 As NativeObject = Parent
    no2.RunMethod("presentViewController:animated:completion:", Array(dialog, True,Null))   
End Sub
then the app crashes without any error.
If i try this code on a button click then this error message appears:
B4X:
Application_Start
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Application_Active
Error occurred on line: 63 (b4xp_add_task)
Application tried to present modally a view controller Page (vc): b4xp_add_task that has a parent view controller <B4INavigationController: 0x107808e00>.
Stack Trace: (
  CoreFoundation       58500388-BF36-397C-84CF-17315A3445B6 + 1217992
  libobjc.A.dylib      objc_exception_throw + 60
  UIKitCore            186C18FD-1082-3811-A761-88E8376C7E69 + 4936076
  UIKitCore            186C18FD-1082-3811-A761-88E8376C7E69 + 4938736
  UIKitCore            186C18FD-1082-3811-A761-88E8376C7E69 + 4939600
  UIKitCore            186C18FD-1082-3811-A761-88E8376C7E69 + 4938556
  UIKitCore            186C18FD-1082-3811-A761-88E8376C7E69 + 4939820
  CoreFoundation       58500388-BF36-397C-84CF-17315A3445B6 + 1239156
  CoreFoundation       58500388-BF36-397C-84CF-17315A3445B6 + 7076
  MyAppName              +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1528
 MyAppName              -[B4INativeObject RunMethod::] + 224
 CoreFoundation       58500388-BF36-397C-84CF-17315A3445B6 + 1239156
 CoreFoundation       58500388-BF36-397C-84CF-17315A3445B6 + 7076
 MyAppName              +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1528
 MyAppName              -[B4IShell runVoidMethod] + 232
 MyAppName              -[B4IShell raiseEventImpl:method:args::] + 1800
 MyAppName              -[B4IShellBI raiseEvent:event:params:] + 1580
 MyAppName              __33-[B4I raiseUIEvent:event:params:]_block_invoke + 56
 libdispatch.dylib    FFC93E7E-8360-32A0-9EB5-FE3761B8C90A + 10836
 libdispatch.dylib    FFC93E7E-8360-32A0-9EB5-FE3761B8C90A + 18412
 libdispatch.dylib    _dispatch_main_queue_callback_4CF + 884
 CoreFoundation       58500388-BF36-397C-84CF-17315A3445B6 + 668152
 CoreFoundation       58500388-BF36-397C-84CF-17315A3445B6 + 643280
 CoreFoundation       CFRunLoopRunSpecific + 600
 GraphicsServices     GSEventRunModal + 164
 UIKitCore            186C18FD-1082-3811-A761-88E8376C7E69 + 12363748
 UIKitCore            UIApplicationMain + 168
 DayPlan              main + 120
 libdyld.dylib        B08AB7C2-64E8-3937-9487-C33D0175FD34 + 7416
)
how can I display a page modally with B4XPages?
1620471921470.png
 
Top