question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS: Cannot set CurrentPage of TabbedPage: only a view controller in the tab bar controller's list of view controllers can be selected.

See original GitHub issue

Hi there, am trying to set the current page for tabbedPage in code but not having too much luck:

(BindingContext as LoginPageModel)?.CoreMethods.SwitchOutRootNavigation(NavigationStacks.MainAppStack);
                                if (Settings.CurrentUser.GetInHouseBooking() == default(CurrentBooking))
                                {
                                    if (Application.Current.MainPage is FreshTabbedNavigationContainer freshTabbedNavigation)
                                    {
                                        Page contentPage = (Page)freshTabbedNavigation.TabbedPages.ElementAt(2);
                                        freshTabbedNavigation.SelectedItem = contentPage;
                                        freshTabbedNavigation.CurrentPage = contentPage;
                                    }
                                }

I can confirm that correct page I want is in fact contentPage when I debug but the page is showing when the tabbedpage loads. I want child page of tabbed page at index 2 but I am getting the tab at index 0 showing which would be the default but am trying to override that.

The tabbedpage has not yet displayed at this point.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13

github_iconTop GitHub Comments

2reactions
libin85commented, May 29, 2019

sample_TabbedPage.zip

Please check the sample, that should do the trick for you. Hope that helps.

0reactions
libin85commented, Jun 3, 2019

Closing this issue @LeoJHarris , but feel free to reopen if u have any issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UITabBarController setSelectedViewController only a view ...
@Jef If the controller is not already in one of the tabs, then you need to add it to the viewControllers array to...
Read more >
Tab bar controller not showing on
The view controller is linked to by a button on the main view controller and when navigated to the the tab bar is...
Read more >
UITabBarController | Apple Developer Documentation
If you don't provide a custom tab bar item for your view controller, the view controller creates a default item containing no image...
Read more >
Xamarin.Forms Namespace
Controls the relative positioning of, and spacing between, ... Enumerates values that control whether items in a list view can or cannot be...
Read more >
Create Tab Bar Controller Programmatically (Swift 5, Xcode 11)
In this video we will learn how to create, configure, and present a tab bar controller fully programmatically through code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found