Closed belmonmi closed 1 year ago
"Tab 1" selected - Shell Title is visible, "Tab 2" selected - Shell Title is visible, back to "Tab 1" - Shell Title disappeared.
I had something similar where I had a Route assigned to a TabBar, but not the child tabs. Added those routes and it fixed the header title updating. It's refreshes slow if adding a new page to a stack, but it happens.
<TabBar Route="home">
<Tab Title="Cats" Route="cats">
<ShellContent Title="Cats" ContentTemplate="{DataTemplate local:MainPage}" />
</Tab>
<Tab Title="Dogs" Route="dogs">
<ShellContent Title="Dogs" ContentTemplate="{DataTemplate local:MainPage}" />
</Tab>
</TabBar>
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Is there a workaround for this? I have an image in titleview and if I read my logs correctly, the image simply gets disposed and is therefore not visible anymore.
this is pretty much a showstopper :/
@nebula2 Exactly! We cannot release as well until it fixed. Application title area has a vital information that has be visible always. BTW: works on Android, no issues. Very frustrated...
@belmonmi
Exactly! We cannot release as well until it fixed. Application title area has a vital information that has be visible always. BTW: works on Android, no issues. Very frustrated...
Jeah i started with designing android . yesterday I got an iPhone to test how the app looks and it was horrible. Spent the whole day fixing the most basic things. I have a readme with a list of issues which is getting bigger and bigger.
There are new issues which may be related to this one here. At least they sound like it.
and
It's terrible that I cannot even change to something else on iOS (like showing simple text, or an icon or whatever) because no matter what you put into there - it will disappear or it will be outdated ( #6582 ).
and seeing issues with "priority high" and "moved to backlog" has it's very own taste :-| Having a very hard time to stay calm >.<
@nebula2 "Having a very hard time to stay calm" - LOL. Your endurance is exceptional!! :)
@belmonmi I worked around it by not using shell at all. I replaced the shell by a combination of NavigationPage and Syncfusion's TabView.
There are disadvantages and I had to rewrite a few parts of my app in order to get this working - but at least my journey can go on.
@nebula2 thank you for the update. We are using Developer Express components; I will check if I can accomplish the same with what they provide.
@belmonmi feel free to contact me if you struggle. A sorrow shared is a sorrow halved
@belmonmi, @nebula2 I just added a workaround here, then remembered this issue. Looks like you might have found a workaround using some Syncfusion components. Unfortunately I was not able to use Syncfusion.
I tested my workaround using the flyout and tabs and it appears to work. It is essentially the same except you would need to add a menu item to your TitleView to present the flyout. I have added an example of how to do this in the repro project in #9269, which I believe is a duplicate.
@belmonmi, @nebula2 I just added a workaround here, then remembered this issue. Looks like you might have found a workaround using some Syncfusion components. Unfortunately I was not able to use Syncfusion.
I tested my workaround using the flyout and tabs and it appears to work. It is essentially the same except you would need to add a menu item to your TitleView to present the flyout. I have added an example of how to do this in the repro project in #9269, which I believe is a duplicate.
Thank you for sharing. Better than my approach. I wrote some fancy stuff that instantiates views instead of pages to render stuff inside the SfTabView, where every tab item is a view and not a page.
attached video shows a Shell TitleView on an iOS device while navigating between Tabs using .NET 7. Sometimes the Title doesn't appear at all, sometimes it moves up, approximately half way out of the window, and sometimes it renders fine. The same TitleView works always as expected on android.
@rachelkang why is this in backlog? Can we expect a fix soon? It seems not possible to show anything else than a plain string in a Title on iOS using AppShell, which is the default template.
Hello @belmonmi @borrmann ,
I fixed the issue by using a custom render for AppShell on iOS.
using CoreGraphics;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Controls.Platform.Compatibility;
using UIKit;
namespace DemoMauiApp.Platforms.iOS.Renderers;
public class CustomShellRenderer : ShellRenderer
{
protected override IShellPageRendererTracker CreatePageRendererTracker()
{
return new CustomShellPageRendererTracker(this);
}
protected override IShellNavBarAppearanceTracker CreateNavBarAppearanceTracker()
{
return new NoLineAppearanceTracker();
}
}
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;
}
public class NoLineAppearanceTracker : IShellNavBarAppearanceTracker
{
public void Dispose() { }
public void ResetAppearance(UINavigationController controller) { }
public void SetAppearance(UINavigationController controller, ShellAppearance appearance)
{
var navBar = controller.NavigationBar;
var navigationBarAppearance = new UINavigationBarAppearance();
navigationBarAppearance.ConfigureWithOpaqueBackground();
navigationBarAppearance.ShadowColor = UIColor.Clear;
navigationBarAppearance.BackgroundColor = UIColor.White; // Set the background color you want on the Shell NavBar
navBar.ScrollEdgeAppearance = navBar.StandardAppearance = navigationBarAppearance;
}
public void SetHasShadow(UINavigationController controller, bool hasShadow) { }
public void UpdateLayout(UINavigationController controller) { }
}
On the MauiProgram.cs configure the handler:
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureMauiHandlers(handlers =>
{
#if IOS
handlers.AddHandler(typeof(Shell), typeof(DemoMauiApp.Platforms.iOS.Renderers.CustomShellRenderer));
#endif
});
Rebuild and Run 💯
I hope this helps others as well! Thank you
Thank you, works like a charm!
Just had to use my inherited class from Shell, in my case AppShell
in MauiProgram.cs
Also I would suggest to set the Backgroundcolor using a saved status, so stuff like AppThemeBinding should still work
public void SetAppearance(UINavigationController controller, ShellAppearance appearance)
{
var navBar = controller.NavigationBar;
var col = navBar.BackgroundColor;
var navigationBarAppearance = new UINavigationBarAppearance();
navigationBarAppearance.ConfigureWithOpaqueBackground();
navigationBarAppearance.ShadowColor = UIColor.Clear;
navigationBarAppearance.BackgroundColor = col;
navBar.ScrollEdgeAppearance = navBar.StandardAppearance = navigationBarAppearance;
}
Woot! That fix worked for us. Thanks!
@vhugogarcia , Thank you very much for the fix you posted. Very simple, elegant solution and the most important thing it is working.
Description
On iOS Simulator with Shell.FlyoutBehavior="Flyout" and Tabs, Shell.TitleView is disappearing on tab change.
Steps to Reproduce
Create new .Net MAUI project.
Add couple ContentPages.
Add "AppTitleView" ContentView
Edit AppShell.xaml to set Shell.FlyoutBehavior="Flyout"
Create couple FlyoutItem with Tab elements.
Add `
Run application, switch from "Tab 1" to "Tab 2"
Pages on the "Tab 1" will not show "Shell.TitleView", but if you named that TitleView control it still accesable from code behind.
Simple project to demostrate the behavior: https://github.com/belmonmi/ShellTitleView
Version with bug
6.0.408
Last version that worked well
Unknown/Other
Affected platforms
iOS, I was not able test on other platforms
Affected platform versions
iOS 15.5
Did you find any workaround?
No
Relevant log output