iOS Question iOS13 show modal popup dialog

Mike1970

Well-Known Member
Licensed User
hi, i saw this post that show partially how to show the new dialog style from Apple.
The only problem is that, even if i had some top/right buttons to the page displayed as dialog, they aren't disaplayed because i think there isn't the navigation bar in that page.

Where i add the button (taken from this example)

B4X:
Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.Yellow
    
    page2.Initialize("Page2")
    page2.Title = "Page 2"
    page2.RootPanel.Color = Colors.Cyan
    
    NavControl.ShowPage(Page1)
    
    
    
    Page1.TopRightButtons = Array( _
     CreateFABarButton(Chr(0xF054), "right") _
     ,CreateFABarButton(Chr(0xF053), "left") _
     ,CreateFABarButton(Chr(0xF00C), "v") _
     ,CreateFABarButton(Chr(0xF00D), "x"))
End Sub
Attempt one:

B4X:
Sub PresentPage2(Parent As Page, dialog As Page)
    Dim no As NativeObject = dialog
    no.SetField("modalTransitionStyle",0)
    'no.SetField("modalPresentationStyle",0)

    Dim no2 As NativeObject = Parent
    no2.RunMethod("presentModalViewController:animated:", Array(dialog, True))
End Sub
IMG_0592.PNG

The shape is this one.. but no top button showed, i think something is missing


Attempt two:

B4X:
Sub PresentPage2(Parent As Page, dialog As Page)
    Dim no As NativeObject = dialog
    no.SetField("modalTransitionStyle",0)
    no.SetField("modalPresentationStyle",0)

    Dim no2 As NativeObject = Parent
    no2.RunMethod("presentModalViewController:animated:", Array(dialog, True))
End Sub
IMG_0593.PNG

this is the result from the Erel answer, for the missing of top control (if there is not layout) i can't even close this page (dialog).


What i'm looking for:
1 JuPvxhMr1isAtYYXG-EDYQ.png

(this has the left button cancel in other cases there is also a sort of title)
 

Semen Matusovskiy

Well-Known Member
Licensed User
I tested an attached project under IOS 14 simulator only. Probably (but not sure) we need some changes for another OSes.

presentModalViewController was deprecated a long time ago. But we can use presentViewController:animated:completion: and dismissViewControllerAnimated:completion:.
To show navigation bar, we can create a new navigation controller and to use it in presentViewController.

Comments to a sample. Click "Show Page 2". Appears pop-up page. Click any navigation bar button.
 

Attachments

Mike1970

Well-Known Member
Licensed User
I tested an attached project under IOS 14 simulator only. Probably (but not sure) we need some changes for another OSes.

presentModalViewController was deprecated a long time ago. But we can use presentViewController:animated:completion: and dismissViewControllerAnimated:completion:.
To show navigation bar, we can create a new navigation controller and to use it in presentViewController.

Comments to a sample. Click "Show Page 2". Appears pop-up page. Click any navigation bar button.
Thanks Semen, I think it will be useful to some people
(me included).
I Will take a look asap
 
Top