dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.77k stars 1.65k forks source link

ios Shell #22452

Open Gekidoku opened 3 weeks ago

Gekidoku commented 3 weeks ago

Description

Im having a small issue with my Shell. This used to work the way i have it right now. but since i installed .net 8.0.5 on my mac and the latest workload it stopped working. In my function I set the mainpage like so

App.AppShell = new AppShellPlanning() { BackgroundColor = Colors.Black };
MainThread.BeginInvokeOnMainThread(async () =>
{
    await Task.Delay(100);
    App.Current.MainPage = App.AppShell;
});

The delay is there for an earlier issue, if didnt stick it in there it would crash sometimes back in ios 16.something.

Now when it executes with XCode 15.2 on an iphone simulator for 17.0 it gets to the last line and then logs this in the console

[TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <_UIMoreListTableView: 0x118af7e00; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x600000cc3cc0>; backgroundColor = <UIDynamicSystemColor: 0x6000017cad00; name = tableBackgroundColor>; layer = <CALayer: 0x600000bc09e0>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <UIMoreListController: 0x1077b4600>>

What is odd is that my shell only has this in it at the moment (stripped everything away to see what was causing it)

 public AppShellPlanning()
 {
     InitializeComponent();       
     Shell.SetTabBarIsVisible(this, false);
     var SplashPage = new FlyoutItem()
     {
         Title = "Dashboard",
         Icon = ImageSource.FromFile("Db.png"),

     };
     SplashPage.Items.Add(new ShellContent()
     {
         Route = "SplashPage",
         ContentTemplate = new DataTemplate(typeof(SplashPage)),

     });

     this.Items.Add(SplashPage);
}

If I change my mainpage code to just set a navigation page of Splashpage then it does work, but I need the shell navigation.

//This works but is not a solution
 MainThread.BeginInvokeOnMainThread(async () =>
 {
     await Task.Delay(100);
     App.Current.MainPage = new NavigationPage(new SplashPage()) { Style = Application.Current.Resources["MyNavPage"] as Style, };
 });

Using visual studio code on mac

Steps to Reproduce

No response

Link to public reproduction project repository

should throw the error on app launch

Version with bug

8.0.21 SR4.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 3 weeks ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Gekidoku commented 3 weeks ago

Attempted to build for ios 17.2 same result. also the same when i build for ios 17.4.

on android this works

RoiChen001 commented 3 weeks ago

Can repro this issue at iOS platform on the latest 17.10 Preview 7(8.0.20&8.0.21).