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

Shell TitleView Not Working in iOS 16 [Bug] #15512

Closed
mmholtman opened this issue Aug 17, 2022 · 76 comments · Fixed by #15667
Closed

Shell TitleView Not Working in iOS 16 [Bug] #15512

mmholtman opened this issue Aug 17, 2022 · 76 comments · Fixed by #15667

Comments

@mmholtman
Copy link

mmholtman commented Aug 17, 2022

Description

Shell content is not visible within a TitleView when testing against iOS 16.

https://github.com/mmholtman/xamarinios16bug.git

Steps to Reproduce

  1. Download xCode 14 beta & get iOS 16 simulators
  2. Create a test Flyout App in Xamarin Forms
  3. Add a label within a <Shell.TitleView> on a XAML View.

Expected Behavior

The title is visible on the view

Actual Behavior

The title is not visible on the view

Basic Information

  • Version with issue: iOS 16 beta
  • Last known good version: any iOS version other than 16
  • Platform Target Frameworks:
    • iOS: 16
  • Affected Devices: iOS 16 devices

Environment

@adam-russell
Copy link

adam-russell commented Aug 25, 2022

Just wanted to second this issue. I see the same thing, and it breaks functionality in an app I have in the App Store.

Using these versions:
Xcode 14 beta 5
Visual Studio for Mac 17.4 build 715
Xamarin.Forms 5.0.0.2515
Xamarin.iOS 15.99.0.335

@bobbydharrell
Copy link

I also have this issue, is there a workaround? I feel this should be a high priority as iOS 16 should roll out in September.

@adam-russell
Copy link

adam-russell commented Aug 26, 2022

I believe this may be a related issue mentioned here from a native Xcode perspective: https://developer.apple.com/forums/thread/712461

Anyway, below is a custom renderer that gets the TitleView showing for me again (and it may just happen to work because of something else I'm doing, not sure). YMMV, this is not well tested at all, and is definitely more of a hack than a long term solution. And there's probably a much cleaner/easier way to do this. I based it off some code from ShellPageRendererTracker.cs, but cut out some of the old iOS support (I tested the super quickly with my specific TitleView and it seems to work on iOS 14+ for me) and some other stuff. There are probably at least some use cases where this doesn't work, because there's extra code that was in TitleViewContainer that I'm just not using below.

I also agree this should be a high priority issue to fix.

Here's the hacky custom renderer:

[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;
    }
}

Edit: updated with the version I've been using.

@adam-russell
Copy link

Just wanted to add, this isn't caused by new tooling. This issue with the TitleView also occurs on a build with older tools on iOS 16.

Just tested on the below versions, and a custom TitleView also does not work on iOS 16 when built with the below:

Xcode 13.4.1
Xamarin.iOS 15.8
Xamarin.Forms 5.0.0.2515

@bobbydharrell
Copy link

@adam-russell Thank you for the workaround!! It worked great!

the only issue I have with the workaround is my TitleView is not bottom aligned rather than centered vertically. Any tidbits on getting that to center using your Renderer? Thanks!

@adam-russell
Copy link

@bobbydharrell So this code (adapted from the example in this issue, but with a red background on a Grid to see the space occupied by the TitleView):

<Shell.TitleView>
    <Grid VerticalOptions="Center" HeightRequest="44" BackgroundColor="Red">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Label TextColor="Orange"
            FontSize="Large"
            FontAttributes="Bold"
            HorizontalTextAlignment="Center"
            VerticalTextAlignment="Center"
            Text="test 2 - 2 test 2 curious">
    </Grid>
</Shell.TitleView>

Shows a TitleView like this:
titleview2

Not sure if that's similar to the bottom alignment you're mentioning? Because the shell menu icon doesn't appear to itself be centered. It does seem the text in the TitleView can be centered OK in this way, but maybe not inside the frame you'd expect. I'm also not sure why I had to set the HeightRequest on the Grid above to get it to work correctly. The one I'm dealing with in a real application doesn't have the HeightRequest set, but works OK. The sizing in Xamarin Forms is often confusing to me. (As an aside, the horizontal alignment is also an issue with the Grid example I used above.. if using a Grid that way in a TitleView, I would personally hack it by adding another column at the end.. which probably isn't the right way to do it.)

@bobbydharrell
Copy link

bobbydharrell commented Sep 2, 2022

@adam-russell Thanks!

I was just thinking it is probably centering but the height is more than what is actually there for some reason.

<Grid.HeightRequest> <OnPlatform x:TypeArguments="x:Double"> <On Platform="iOS" Value="44"/> </OnPlatform> </Grid.HeightRequest>

And yes, the Horizontal Alignment is trash on a Custom TitleView. The menu button seems to be part of the space and pushed the Title over. I wrote custom adjusters using columns with nothing in them to get it centered per platform per idiom. It's gross but effective. Be nice if they fixed that also LOL

Code for Horizontal Alignment:

This allows me to center the title as the Title control is pushed by the Menu Button
<Grid.Margin> <OnPlatform x:TypeArguments="Thickness"> <On Platform="Android" Value="-72,0,0,0"/> <On Platform="iOS" Value="-57,0,0,0"/> </OnPlatform> </Grid.Margin> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" x:Name="SpacingColumn"/> <ColumnDefinition Width="*" x:Name="TitleColumn"/> <ColumnDefinition Width="56" x:Name="ButtonColumn"/> </Grid.ColumnDefinitions>

This is to provide a buffer for the menu button for alignment
<BoxView Grid.Column="0"> <BoxView.WidthRequest> <OnPlatform x:TypeArguments="x:Double"> <On Platform="iOS">57</On> <On Platform="Android">72</On> </OnPlatform> </BoxView.WidthRequest> </BoxView>

@mphill
Copy link

mphill commented Sep 13, 2022

Can we get an update on this issue? All Xamarin apps that use Shell TitleView are now functionally broken in iOS 16 - the content won’t show. If you have important navigation features your Shell TitleView it’s a big problem.

@bobbydharrell
Copy link

@mphill we have a working workaround using a iOS Renderer above so that you can get your apps back up and running.

@mphill
Copy link

mphill commented Sep 13, 2022

To anyone using the fix from @adam-russell (thank you so much). If the TitleView is still blank, make sure you specify a RowDefintion or RequestHeight if using a Grid.

You can also try VerticalOptions="Start"

Otherwise the content will sort of slide down behind and not show.

Hopefully this gets fixed soon!

@roughiain
Copy link

roughiain commented Sep 14, 2022

occurring on builds using Xcode 13.4.1

Visual Studio Community 2022 for Mac
Version 17.3.3 (build 10)
Installation UUID: 1b89bb56-5bbb-453a-a7b1-efe28fc4be3d

Runtime
.NET 6.0.5 (64-bit)
Architecture: Arm64

Roslyn (Language Service)
4.3.0-3.22312.2+52adfb8b2dc71ed4278debcf13960f2116868608

NuGet
Version: 6.2.1.2

.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/6.0.400/Sdks
SDK Versions:
	6.0.400
	6.0.400-preview.22330.6
	6.0.302
	6.0.301
	6.0.300
	6.0.203
	6.0.202
	6.0.201
	6.0.200
	6.0.101
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET SDK (x64)
SDK Versions:
	6.0.400
	6.0.400-preview.22330.6
	6.0.302
	6.0.301
	6.0.300
	6.0.203
	6.0.202
	6.0.103
	5.0.408
	5.0.407
	5.0.406
	3.1.422
	3.1.421
	3.1.420
	3.1.419
	3.1.418
	3.1.417

.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	6.0.8
	6.0.7
	6.0.6
	6.0.5
	6.0.4
	6.0.3
	6.0.2
	6.0.1

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/x64/dotnet
Runtime Versions:
	6.0.8
	6.0.7
	6.0.6
	6.0.5
	6.0.4
	6.0.3
	5.0.17
	5.0.16
	5.0.15
	3.1.28
	3.1.27
	3.1.26
	3.1.25
	3.1.24
	3.1.23

Xamarin.Profiler
Version: 1.8.0.19
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 13.4.1 (20504)
Build 13F100

Xamarin.Mac
Version: 8.12.0.2 (Visual Studio Community)
Hash: 87f98a75e
Branch: d17-3
Build date: 2022-07-25 20:18:54-0400

Xamarin.iOS
Version: 15.12.0.2 (Visual Studio Community)
Hash: 87f98a75e
Branch: d17-3
Build date: 2022-07-25 20:18:55-0400

Xamarin Designer
Version: 17.3.0.208
Hash: 0de472ea0
Branch: remotes/origin/d17-3
Build date: 2022-08-25 17:15:19 UTC

Xamarin.Android
Version: 13.0.99.36 (Visual Studio Community)
Commit: xamarin-android/main/b4998c8
Android SDK: /Users/iainrough/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		12.0 (API level 31)
		11.0 (API level 30)
		10.0 (API level 29)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 33.0.2
SDK Build Tools Version: 33.0.0

Build Information: 
Mono: dffa5ab
Java.Interop: xamarin/java.interop/main@032f1e71
SQLite: xamarin/sqlite/3.39.2@40e8743
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@9c641b3

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.12
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.3.0.23
Hash: 965bf40
Branch: remotes/origin/d17-3
Build date: 2022-08-25 17:15:24 UTC

Android Device Manager
Version: 0.0.0.1169
Hash: fafb1d5
Branch: fafb1d5
Build date: 2022-08-25 17:15:24 UTC

Build Information
Release ID: 1703030010
Git revision: d50fe2cc8bfbdfddb716bda6a920f1eb6c0c2c63
Build date: 2022-08-25 17:12:45+00
Build branch: release-17.3
Build lane: release-17.3

Operating System
Mac OS X 12.6.0
Darwin 21.6.0 Darwin Kernel Version 21.6.0
    Mon Aug 22 20:20:05 PDT 2022
    root:xnu-8020.140.49~2/RELEASE_ARM64_T8101 arm64

Enabled user installed extensions
NuGet Package Explorer 0.10
NuGet Package Management Extensions 0.32
VisualStudio View Inspector 0.9.1

@jsuarezruiz jsuarezruiz added a/shell 🐚 p/iOS 🍎 and removed s/unverified New report that has yet to be verified labels Sep 14, 2022
@Saccomani
Copy link

same issue here

@decv86
Copy link

decv86 commented Sep 15, 2022

should i wait for a fix? or Maui is our everything...

@rudyspano
Copy link

Hi. We have implemented the workaround proposed by @adam-russell and now our app is fixed in Prod.
I think you should all give it a try. Nothing complicated and that's a chance to have the ability to override/enhance/fix things in XF/MAUI...

@jsuarezruiz
Copy link
Contributor

public override CGSize IntrinsicContentSize => UILayoutFittingExpandedSize;

Will be a fix in Xamarin.Forms and of course also changed on .NET MAUI.

@adam-russell
Copy link

@jsuarezruiz I might be wrong, but doesn't TitleViewContainer already have public override CGSize IntrinsicContentSize => UILayoutFittingExpandedSize; in Xamarin Forms? Do you mean strip out some of the other code that's in that class like Frame and WillMoveToSuperview? (Feel free to correct me if I'm missing something/misinterpreting anything.)

@edgiardina
Copy link

edgiardina commented Sep 15, 2022

This fix causes my titleview to be visible again, but its shifted up compared to the old appearance. and when implemented with a SegmentedControl I'm using off nuget, appears to be missing until I switch segments.

In this video you can see the My Activity Title should be visible on page load and its not. And in the existing Forms implementation, showing/hiding the visibility of an imagebutton in the titleview's horizontal stacklayout shifts the title label.

RPReplay_Final1663257250.MP4.mp4

Basically, while this fix somewhat resolves the issue of a completely missing titlebar, its not restoring the same layout and sizing that was present previously. we have a Searchbar control in another page's titleview and that's also not sizing as before.

image

@adam-russell
Copy link

adam-russell commented Sep 15, 2022

@edgiardina Yeah, the workaround definitely isn't quite right. I think there may be some differences in the underlying iOS TitleView, too, since I can't get it to be as wide as it was in previous iOS versions. In my particular implementation, I have different hacks in it that are dependent on iOS version to shift it around.

The current Xamarin.Forms implementation has extra code for sizing, but I think it's what's breaking the TitleView in iOS 16. That's stripped out of the custom renderer, but the Height in particular is often a problem, and I certainly don't understand why it works sometimes without having to force a HeightRequest/etc.

You could maybe try to set a static HeightRequest on your TitleView that's missing until the SegmentedControl is switched or maybe set the orientation as others have mentioned above? Just a guess, and I agree it probably shouldn't be needed.

On the image button, personally I would use a Grid rather than a StackLayout and set the width of the column containing the image button to a static value. I would sort of expect the StackLayout to shift when setting visibility of one of its children. I use Grids because the TitleView has changed sizing multiple times in the time I've been using Xamarin Forms, and I've unfortunately changed sizing hacks in it multiple times as new versions of Xamarin Forms are released. Sorry that's probably not super helpful, but just some thoughts.

@edgiardina
Copy link

@adam-russell that's actually really helpful. Luckily we are only using titleviews in 5 of our 40+ views so I will try hacking some heights or converting them to grids to see how it renders. These are good suggestions.

@ianvink
Copy link

ianvink commented Sep 17, 2022

I can confirm on our large app with tens of thousands of users that the CustomShellRenderer from @adam-russell works in iOS 16

@michaelonz
Copy link

I'm seeing the same as @npostma - using version 5.0.0.2545 - note that it is now also an issue on Android as well.
This makes apps look very unprofessional like it is and needs to be a higher priority .... I cant move to Maui yet as 1/2 the libraries I am using are not yet ported to Maui - feel like we are stuck in no mans land at the moment with a broken Xamarin and a 1/2 implemented MAUI.

Below is my TitleBarView.xaml (its fairly simple its display one of 2 images for connection status and 2 labels).

ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyApp.Views.TitleBarView"
               xmlns:c="clr-namespace:MyApp.Converters"
             x:Name="thistitlebar" 
             > 
        <ContentView.Resources>
        <c:NegativeBooleanConverter x:Key="NegativeBooleanConverter" />
    </ContentView.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>
        <Label Grid.Column="0" HorizontalTextAlignment="Center" TextColor="White" HorizontalOptions="StartAndExpand" VerticalOptions="Center" FontSize="Title" FontAttributes="Bold" Text="{Binding  PageTitle, Source={x:Reference thistitlebar}}"></Label>


       <Image Grid.Column="1" IsVisible="{Binding IsConnected , Source={x:Reference thistitlebar}}" HorizontalOptions="Center" MinimumHeightRequest="15" Margin="3,-5,0,3"  VerticalOptions="Center" >
            <Image.Source>
                <FontImageSource  Color="{Binding  ConnectionStatusColor,   Source={x:Reference thistitlebar}}" FontFamily="{DynamicResource IconFontFamily}" Glyph="{StaticResource IconLink}"/>
            </Image.Source>
        </Image>
        
        <Image Grid.Column="1" IsVisible="{Binding IsConnected,  Converter={StaticResource NegativeBooleanConverter} ,   Source={x:Reference thistitlebar}}" HorizontalOptions="Center" MinimumHeightRequest="15" Margin="3,-5,0,3"  VerticalOptions="Center" >
            <Image.Source>
                <FontImageSource  Color="{Binding  ConnectionStatusColor,   Source={x:Reference thistitlebar}}" FontFamily="{DynamicResource IconFontFamily}" Glyph="{StaticResource IconLinkBroken}"/>
            </Image.Source>
        </Image>
        <Label  Grid.Column="1" HorizontalOptions="End" IsVisible="{Binding IsKiosk, Source={x:Reference thistitlebar}}"  Margin="3,0,0,0"  Text="{Binding  ConnectionStatus, Mode=TwoWay, Source={x:Reference thistitlebar}}" FontSize="Small" VerticalTextAlignment="End" MinimumWidthRequest="1200" TextColor="White" ></Label>

    </Grid>
</ContentView>

@npostma
Copy link

npostma commented Jan 6, 2023

Why isn't this reopend yet? It it still broken on the latest xamarin.

Als @michaelonz porting to MAUI wont save you. I am porting my app from xamarin to MAUI, and there the issue is exactly the same. I hoped MAUI would fix some issues i am having with Xamarin, but alas.

There it is still open:

dotnet/maui#9269

@borrmann
Copy link

borrmann commented Jan 6, 2023

As a workaround you can set Shell.NavBarIsvisible to false and just create your own titleview. That works in Xamarin.Forms and MAUI.
In my solution I use 2 different ControlTemplates, one for RootPages (any page without back navigation) and BasePages for any Page that has back navigation. That works pretty well and also comes with more flexibility in the design, as well as the option to create more ControlTemplates for more complex pages

@npostma
Copy link

npostma commented Jan 7, 2023

As a workaround you can set Shell.NavBarIsvisible to false and just create your own titleview. That works in Xamarin.Forms and MAUI. In my solution I use 2 different ControlTemplates, one for RootPages (any page without back navigation) and BasePages for any Page that has back navigation. That works pretty well and also comes with more flexibility in the design, as well as the option to create more ControlTemplates for more complex pages

Sometimes i used the title property but mostly I (already) use the TitleView. Like so:

    <Shell.TitleView>
        <StackLayout 
            Style="{DynamicResource PageTitleHeaderStack}"
        >
            <Label 
                Style="{DynamicResource PageTitleHeaderLabel}"
                Text="{x:Static resources:Localization.MenuItemPageLabel}"
            />
        </StackLayout>
    </Shell.TitleView>

I had Shell.NavBarIsVisible="False" not set. I've added it to my ContentPage but now it gets worse. The black top bar where the title should be became white (and empty). Also then the hamburger icon is gone.

@borrmann
Copy link

borrmann commented Jan 7, 2023

@npostma
Yes, when you set Shell.NavBarIsVisible to false you have a blank page.
That way you can design the title yourself. You can easily reuse your contentviews where you created your own titles and create a simple content view with just a label where you only have a string in your title.
use a grid with a row for your titles or whatever layout you prefer.
To get the hamburger icon simply put an image button in the top left corner. For consistent design I would recommend to use a controltemplate on your pages.

@borrmann
Copy link

borrmann commented Jan 7, 2023

        <Grid RowDefinitions="50,*" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" BackgroundColor="{DynamicResource Background}" Background="{DynamicResource Background}">
            <Grid ColumnDefinitions="40,10,*" VerticalOptions="Center" HorizontalOptions="FillAndExpand" BackgroundColor="{DynamicResource Background}" 
              Background="{DynamicResource Background}">

                <ImageButton Grid.Column="0" Margin="0"  Command="{TemplateBinding BindingContext.NavigateBackCommand}" Background="Transparent">
                    <ImageButton.Source>
                        <FontImageSource FontFamily="{StaticResource IconFontFamily}" Glyph="{StaticResource IconChevronLeft}" Color="{StaticResource Primary}" Size="70"/>
                    </ImageButton.Source>
                </ImageButton>

                <Label Grid.Column="2"  Text="{TemplateBinding BindingContext.Title}" 
                                   FontSize="20" 
                                   HorizontalTextAlignment="Start" 
                                   HorizontalOptions="Start"
                                   VerticalTextAlignment="Center" LineBreakMode="TailTruncation" 
                                   VerticalOptions="Center" FontAttributes="Bold"  Opacity="1" TextColor="{DynamicResource Text}"  />

                <ActivityIndicator Grid.Column="2"   HeightRequest="20" WidthRequest="20" Color="{DynamicResource Text}"
                                                HorizontalOptions="End" Margin="15,0" VerticalOptions="Center"
                                                IsRunning="{TemplateBinding BindingContext.IsLoading}" IsVisible="true"/>
            </Grid>

            <ContentPresenter Grid.Row="1" ZIndex="2" />

            <ActivityIndicator Grid.RowSpan="2" ZIndex="99999" IsRunning="{TemplateBinding BindingContext.IsPosting}"  IsVisible="{TemplateBinding BindingContext.IsPosting}" 
                                                        VerticalOptions="Center" WidthRequest="50" HeightRequest="50" />
        </Grid>
    </ControlTemplate> 

And then on your page use it like this

<ContenPage Shell.NavBarIsVisible=“false” ControlTemplate={x:StaticRessource BasePage}…>

hope this makes sense now. Like I initially said create at least one more ControlTemplate for those pages without back navigation, add your hamburger menu and create as many more templates as you like. You also have to add the NavigateBackCommand in your BaseViewModel which should just be something like Shell.Navigation.GoToAsync(“..”) or whatever type of navigation you use. In my example I also have a LoadingIndicator and a PostingIndicator which are in my BaseViewModel as bool properties.

@robertmaxted
Copy link

Hi all, the issue is still present.. When will an official fix be ready? The custom renderer is a great patch for no, however when migrating to MAUI when MAUI is "ready" for us all. The customer renderers will cause a real nightmare in the migration process.. @jfversluis is there an official fix on the horizon? (p.s - huge fan of your YT channel)

@michaelonz
Copy link

michaelonz commented Jan 10, 2023

Hi Xamarin team - One thing that I have noticed that may help with a fix - if you have a tab page with tab pages within it then the titlebar will always draw correctly - so having the tabpage children appears to cause some sort of re layout call that resolves the issue...maybe that could help find a fix that isn't a lot of work.....just thought i would mention it as its consistent - in my app i have 5 tab pages , within one of them i have 3 children tab pages.....the page with the children will always draw the title bar correctly - all the others are hit and miss.
Also note this is not IOS Specific - android suffers the same issues.

@simonemarra

This comment was marked as off-topic.

@robertmaxted

This comment was marked as off-topic.

@simonemarra

This comment was marked as off-topic.

@Saccomani

This comment was marked as off-topic.

@robertmaxted
Copy link

@adam-russell Thank you for sharing your custom renderer with us all. It solves the issue for now. I just hope Microsoft provide us with an actual fix. Kind regards, Rob

@roughiain
Copy link

looks like this is now fixed on Maui dotnet/maui#12834

@npostma
Copy link

npostma commented Mar 9, 2023

Hi @jfversluis

I've tested the fix, but for me its better, but not quite correct.
image

Red is the container, green the label. What ever i do the container always behaves like this. I can change heightrequest, verticalOptions, margins, paddings but the behavior is always the same, container is first stretched and the second, third, etc time tightly wrapped around the label.

Also it does not matter if i use a stacklayout or a grid, outcome is always the same.

image

I use this simple layout as header:


    <Shell.TitleView>
        <StackLayout 
            Style="{DynamicResource PageTitleHeaderStack}"
        >
            <Label 
                Style="{DynamicResource PageTitleHeaderLabel}"
                Text="About"
            />
        </StackLayout>
    </Shell.TitleView>

Style:

<Style x:Key="PageTitleHeaderStack" TargetType="StackLayout">
                <Setter Property="HorizontalOptions" Value="CenterAndExpand"/>
                <Setter Property="VerticalOptions" Value="CenterAndExpand"/>
            </Style>

 <Style x:Key="PageTitleHeaderLabel" TargetType="Label">
                <Setter Property="VerticalOptions" Value="CenterAndExpand"/>
                <Setter Property="HorizontalOptions" Value="Center"/>
                <Setter Property="TextColor" Value="{StaticResource PrimaryText}"/>
                <Setter Property="FontSize" Value="Medium"/>
                <Setter Property="FontFamily" Value="ExtraBold" />
                <Setter Property="FontAttributes" Value="None" />
		<Setter Property="HeightRequest" Value="22"/>
</Style>

[EDIT]
Code above (#15512 (comment)) does work, so good enough i guess :-)

@EddieBhoy
Copy link

EddieBhoy commented May 15, 2023

This Custom renderer works a treat for me. However, I already had another Custom Renderer in place to show badges on Tab Icons. Is there any way to combine the two or to add both renderers and have them both work? When I add them both in the MauiProgram, only the second one takes effect.

@adam-russell
Copy link

@EddieBhoy Yes, you should just be able to merge the code manually from both custom renderers into a single custom renderer (so that you only have one custom renderer for Shell which does all the things you want).

@EddieBhoy
Copy link

Thanks Adam - worked a treat - I now have a Titlebar logo and Tab Badges!

@ksoftllc
Copy link

ksoftllc commented Jun 12, 2023

We found a solution that works for us.

Our case:

  • Every time we navigated to a root ShellContent view, the Shell.TitleView contents did not render on iOS
  • If you pushed some other view then popped back to that same view, the TitleView did render on iOS

What fixed it (combination of things)

  1. Put contents into a Grid with VerticalOptions="Start"

`
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
...>

<Grid VerticalOptions="Start">`
  1. Then force a height request if iOS platform (as suggested by @bobbydharrell):

<Grid.HeightRequest> <OnPlatform x:TypeArguments="x:Double"> <On Platform="iOS" Value="44"/> </OnPlatform> </Grid.HeightRequest>

@mcapplication20
Copy link

We found a solution that works for us.

Our case:

  • Every time we navigated to a root ShellContent view, the Shell.TitleView contents did not render on iOS
  • If you pushed some other view then popped back to that same view, the TitleView did render on iOS

What fixed it (combination of things)

  1. Put contents into a Grid with VerticalOptions="Start"

` <ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" ...>

<Grid VerticalOptions="Start">`
  1. Then force a height request if iOS platform (as suggested by @bobbydharrell):

<Grid.HeightRequest> <OnPlatform x:TypeArguments="x:Double"> <On Platform="iOS" Value="44"/> </OnPlatform> </Grid.HeightRequest>

ehi you saved my day, it seems it works like a charm. I don't know if it's the best solution but anyway right now, it's working

@dpozimski
Copy link

It works for static content, unfortunately not for buttons or click behaviours.

@bobbydharrell
Copy link

It works for static content, unfortunately not for buttons or click behaviours.

I have buttons on mine and they work fine. Share some code.

@AinhoaErkizia
Copy link

Thank you all.

@bricefriha
Copy link

It's still not working for me

@bobbydharrell
Copy link

It's still not working for me

Did you try the work around we posted? Most all of us have prolly been busy porting to MAUI recently lol.

Post a code snippet and we can have a look.

@bricefriha
Copy link

It's still not working for me

Did you try the work around we posted? Most all of us have prolly been busy porting to MAUI recently lol.

Post a code snippet and we can have a look.

I tried the workaround, indeed and it didn't work for me. No, I get you're all busy with MAUI, don't worry, and I respect that 😊, I just wanted to let people know that I'm still facing the issue.

@bricefriha
Copy link

Hi there,
I think it would be handy to get this officially fixed by May.
Since you are all busy with porting the app to MAUI I could take a look myself?

Since we have a workaround, (that doesn't work for me personally), do we know what is exactly causing the issue? 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.