Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Shell TitleView and ToolBarItems rendering strange display on iOS 16 #15565

Closed
pcdus opened this issue Oct 14, 2022 · 1 comment · Fixed by #15604
Closed

[Bug] Shell TitleView and ToolBarItems rendering strange display on iOS 16 #15565

pcdus opened this issue Oct 14, 2022 · 1 comment · Fixed by #15604

Comments

@pcdus
Copy link

pcdus commented Oct 14, 2022

Description

Since iOS 16, the Shell TitleView is not longer displayed, as described in this bug 15512.

The workaround is to use a custom renderer dedicated to iOS 16 like this:

[assembly: ExportRenderer(typeof(Shell), typeof(CustomShellRenderer))]
namespace Your.Namespace.Here
{
    public class CustomShellRenderer : ShellRenderer
    {
        protected override IShellPageRendererTracker CreatePageRendererTracker()
        {
            return new CustomShellPageRendererTracker(this);
        }
    }

    public class CustomShellPageRendererTracker : ShellPageRendererTracker
    {
        public CustomShellPageRendererTracker(IShellContext context)
            : base(context)
        {

        }

        protected override void UpdateTitleView()
        {
            if (ViewController == null || ViewController.NavigationItem == null)
                return;

            var titleView = Shell.GetTitleView(Page);

            if (titleView == null)
            {
                var view = ViewController.NavigationItem.TitleView;
                ViewController.NavigationItem.TitleView = null;
                view?.Dispose();
            }
            else
            {
                var view = new CustomTitleViewContainer(titleView);
                ViewController.NavigationItem.TitleView = view;
            }
        }
    }

    public class CustomTitleViewContainer : UIContainerView
    {
        public CustomTitleViewContainer(View view) : base(view)
        {
            TranslatesAutoresizingMaskIntoConstraints = false;
        }

        public override CGSize IntrinsicContentSize => UILayoutFittingExpandedSize;
    }
}

But even if the TitleView is now displayed on iOS 16, there is strange behaviour if there are ToolBarItems that are displayed at the same time, like if the TitleView is firstly displayed without the ToolBarItems, then displayed again after the display of the ToolBarItems.

This only occurs with iOS 16, and occurs each time the screen is displayed. On older versions of iOS it's not the case: there is short delay at the first display, but after that the title doesn't seem to be re-displayed.

Here are 3 small videos illustrating this issue: the issue occurs on the "Rendez-vous" Title display.

Steps to Reproduce

  1. Create a test Flyout App in Xamarin Forms
  2. Add a label within a <Shell.TitleView> on a XAML View.
  3. Add ToolbarItems on the same XAML View.

Expected Behavior

The TitleView should be display at the same time as the ToolBarItems.

Actual Behavior

The TitleView is not display at the same time as the ToolBarItems.

Basic Information

  • Version with issue: iOS 16.0
  • Last known good version: any iOS version other than 16
  • Platform Target Frameworks:
    • iOS: iOS 16.0

Screenshots

See videos on iOS 16.0, 15.3 and 13.3:
https://we.tl/t-rG4EMrhJfm

@pcdus pcdus added s/unverified New report that has yet to be verified t/bug 🐛 labels Oct 14, 2022
@Redth Redth added this to To Do in 5.0.0 SR13 Nov 8, 2022
@jsuarezruiz jsuarezruiz self-assigned this Nov 11, 2022
@jsuarezruiz jsuarezruiz added a/shell 🐚 p/iOS 🍎 and removed s/unverified New report that has yet to be verified labels Nov 11, 2022
@jfversluis
Copy link
Member

Hey @Goldstrike, a PR (#15604) for this is open now, would you be able to grab the NuGet as described here and let us know if this fixes this issue? That will greatly speed up the review process.

Besides verifying if this particular issue is fixed also be sure to check other scenarios in the same area to make sure that this fix doesn't accidentally has side-effects 🙂

Thanks!

5.0.0 SR13 automation moved this from To Do to Done Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants