Setting icon for all tabs at app launch


I’m trying to set the icons of an iPhoneLayout TabBar at app launch. Rather than set them to a bundled picture I am trying to use Picture.SystemImage().

I have two screens and the app layout is tabbed. In each screen’s Opening() event I set the screen’s tab bar icon like so:

Me.TabIcon = Picture.SystemImage("", 16)

This works except the icon only appears once the screen has been presented (presumably because that’s when the Opening() event fires). I can’t figure out where in the app’s lifecycle to set the tab icons so they appear at launch. I have tried multiple approaches but can’t get it to work.

Here it is in the IDE:

Here’s a picture at first launch. Notice only the visible screen displays it’s icon in the tab bar:

If I click the “Insight” tab the icon finally displays:

Cast App.Currentlayout.content to a iostabbar and you should be able te change them all.

I thought of that by putting this in App.Opening():

iOSTabBar(Self.CurrentLayout.Content).IconAt(1) = _
Picture.SystemImage("", 16)

but the app crashes at launch because App.CurrentLayout is Nil.

Do this in opening of the first view, not in app events

Or maybe better set all to a single view (default in app) the create the tabbar in code and set it all then open that tabbar once setup.

Hmm. Interesting. How do you embed a screen in a tab bar in code rather than using the IDE designer?

Iosdesignextentions has sample code for this.

Or see here:

1 Like

Not sure it’s helpful but I allow my users to add/delete/move the tabs in my app. After they make changes to the layout I create a new iOSTabBar, add the various MobileScreens to it and then set the CurrentLayout.Content to this iOSTabBar in the Activated event of the main/permanent MobileScreen. I call it the “main/permanent” MobileScreen because I had to force one particular MobileScreen (this one) to always be in the layout in order to make this feature work, ie users can move it but, unlike the other tabs, they can’t remove it as it is the “controller” of all the other tabs as it sets up the UI in its own Activated event.

1 Like