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
22.28k stars 1.76k forks source link

Shell.TitleView is not replacing the Shell.Title on iOS 18 iPad only. #26114

Open GorillaSpring opened 6 days ago

GorillaSpring commented 6 days ago

Description

This works on iOS 17.5 iPad, but not on iOS 18 iPad (works on iOS 18 phone). Verified on physical device. Screenshots are from simulators running the SAME code.

Steps to Reproduce

Modify AppShell.xaml

<ShellContent Title="HIDE ME" ContentTemplate="{DataTemplate local:AttendPage}" Route="AttendPage" />

And

`

</Shell.TitleView>`

in ios17.5 (and previous versions) this works as expected. The title view is the label.

in iOS 18, the Title ("HIDE ME") is showing up and taking up vertical room.

Note. I am running VS 17.13.3527.3 (this is preview as trying to work around another issue).

IOS Manifest Version (form donent workload list) is: 18.0.9600-net9-rc2/9.0.100-rc.2

Image

Image

Link to public reproduction project repository

No response

Version with bug

9.0.10 SR1

Is this a regression from previous behavior?

Not sure, did not test other versions, Yes, this used to work in .NET MAUI

Last version that worked well

9.0.10 SR1

Affected platforms

iOS

Affected platform versions

iOS 18

Did you find any workaround?

No response

Relevant log output

Ying-6 commented 5 days ago

I created a Maui template project and modified the code without repro your issue. Could you provide us with a sample project so we can investigate it further? Looking forward to your reply!

jfversluis commented 5 days ago

Are you sure you are using .NET MAUI 9.0.10 SR1?

A change is merged in this version that should fix this I think. In your csproj what does the entry for Microsoft.Maui.Controls say for the Version field? Could you change that to 9.0.10 if its not on that already and try again?

GorillaSpring commented 5 days ago

@jfversluis , I am not sure on the version. When I run dotnet workload list, I get this: IOS Manifest Version : 18.0.9600-net9-rc2/9.0.100-rc.2

I did find this: https://github.com/dotnet/maui/issues/23380.

I think this is the same issue. This is related to the tab bar,

There is a workaround listed. I will try and see if I can get that in place.

` public class CustomShellRenderer : ShellRenderer { protected override IShellItemRenderer CreateShellItemRenderer(ShellItem item) { var renderer = base.CreateShellItemRenderer(item);

    if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && UIDevice.CurrentDevice.CheckSystemVersion(18, 0) && renderer is ShellItemRenderer shellItemRenderer)
        shellItemRenderer.TraitOverrides.HorizontalSizeClass = UIUserInterfaceSizeClass.Compact;

    return renderer;
}

} `

GorillaSpring commented 5 days ago

OK. I can confirm that the above solution solved the issue. (well in the simulator so far, but should be good.)

My Class: CustomShellRenderer.cs (in Platforms/iOS)

using UIKit;

namespace AttendProf.Platforms.iOS;

public class CustomShellRenderer : ShellRenderer
{
    protected override IShellItemRenderer CreateShellItemRenderer(ShellItem item)
    {
        var renderer = base.CreateShellItemRenderer(item);

        if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && UIDevice.CurrentDevice.CheckSystemVersion(18, 0) && renderer is ShellItemRenderer shellItemRenderer)
            shellItemRenderer.TraitOverrides.HorizontalSizeClass = UIUserInterfaceSizeClass.Compact;

        return renderer;
    }
}

In MauiProgram.cs

...
                .ConfigureMauiHandlers(static handlers =>
                    handlers.AddHandler<GsHybridWebView, GsHybridWebViewHandler>()
#if IOS
                    .AddHandler(typeof(Shell), typeof(CustomShellRenderer))
#endif             

                    );
WebGoose commented 5 days ago

@GorillaSpring Thank you. This solution solved the problem for me as well in .Net 8

GorillaSpring commented 4 days ago

Just to be sure the MS guys are aware. My project is .Net 8 Long Term. The "dotnet workload list" was really confusing. Maybe you should ask what the project is using instead of that.