MobilesScreen.Show cannot determine parent view

In my iOS project I have a TabBar which shows a mobile screen Screen1. On that screen, I have a button which is supposed to show another mobile screen Screen2 with this code:
var ms as new Screen2
ms.show

Tapping the button gives me a NilObjectException:

Unable to determine parent view. Try passing it in instead.

See the attached sample project. What is wrong with the code and how can I show another screen with a TabBar?

https://www.amazon.de/clouddrive/share/qYLl4f6c2vm3IWvi2NKTZVZ536gS2pxKj0ULrpge0Sr

Thank you
Christoph

Show is for Modal views. Try PushTo.

PushTo is API 1.0, no? It’s still available but it requires an iOSView and I don’t have that anymore in my app. I only have MobileScreens now.

Also, there is Show and ShowModal where the latter would be for showing modal screens. Show works in all other cases for me except when there is a TabBar involved.

Heh, you are correct. It’s a little early here.

Does this work?

ms.Show(self)

Unfortunately not. I tried it this morning and debugged it step-by-step but the debugger would skip the “Opening” and “Activated” events and go right to the “Closing” event of the MobileScreen. Without stopping in the debugger, nothing happens on the screen, so you won’t even see the screen open and close.

I also tried other screens as parent screens but none seem to work.

I have just filed a bug report: <https://xojo.com/issue/64114>

Tested the example project, this does work for me (in the simulator).

I do see you are using a TabBar. perhaps you may wanna try ms.ShowModal instead and passing in the parent screen ?

https://documentation.xojo.com/api/user_interface/mobile/mobilescreen.html#mobilescreen-showModal

1 Like

CORRECTION: ms.show(self) works. I tried to simplify the sample project. In my project there is an iOSMobileTable that’s causing the issue. Trying to show the MobileScreen from the SelectionChanged event does not work.