Bug 52620 - [iOS] Header in MasterDetailPage overwrites status bar
Summary: [iOS] Header in MasterDetailPage overwrites status bar
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Chris King
URL:
Depends on:
Blocks:
 
Reported: 2017-02-19 11:55 UTC by Michael Rumpler
Modified: 2017-10-13 14:00 UTC (History)
5 users (show)

See Also:
Tags: AC
Is this bug a regression?: Yes
Last known good build: 2.3.3.180


Attachments
Repro project (146.00 KB, application/x-zip-compressed)
2017-02-19 11:55 UTC, Michael Rumpler
Details
Screenshot (74.36 KB, image/png)
2017-02-19 11:56 UTC, Michael Rumpler
Details

Description Michael Rumpler 2017-02-19 11:55:01 UTC
Created attachment 19878 [details]
Repro project

I have a MasterDetailPage with MasterBehavior.Split and NavigationPages in both Master and Detail. So on the iPad both Master and Detail should always be visible.

In Xamarin.Forms 2.3.4.192-pre2 has a regression that the header does not have the correct height. The status bar (WiFi status, clock, battery) is not visible and the top of the Master page is overlapped by the Master header. See screenshot.

This bug only shows, when you open the app in landscape mode on the iPad. If you open it in portrait then everything is ok. If you rotate the tablet after the app was started, then the header positions stay as they are. If they were wrong at app start, then they stay wrong after rotation.

It worked as expected in Xamarin.Forms 2.3.3.180.
Comment 1 Michael Rumpler 2017-02-19 11:56:12 UTC
Created attachment 19879 [details]
Screenshot
Comment 2 Chris King 2017-03-16 20:13:05 UTC
Apparently, on iOS, when opening a page in portrait mode, by default, a page will report it wants the status bar is hidden. See ChildViewControllerForStatusBarHidden in https://github.com/xamarin/Xamarin.Forms/blob/199edb166b8c887a946a377e86191f7d1b63def3/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/NavigationPage.cs#L234
 and commit: https://github.com/xamarin/Xamarin.Forms/commit/98235e0eea8b540ac10a71b97ee08a5842abd664

Will circle back with team to see if we want to change this default. 

Meanwhile, you can force the status bar to always be visible:. 

using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using static Xamarin.Forms.PlatformConfiguration.iOSSpecific.Page;

namespace MasterDetailHeader {

    public class App : Application {

        public App() {

            var mdp = new MasterDetailPage() {
                MasterBehavior = MasterBehavior.Split,
                BackgroundColor = Color.Black,
                Master = new NavigationPage(
                    new ContentPage() {
                        Title = "Master",
                        Content = new Label { Text = "Master" }
                    }
                ) { Title = "foobar" },
                Detail = new NavigationPage(
                    new ContentPage() {
                        Title = "Detail",
                        Content = new Label { Text = "Detail" }
                    }
                ),
            };

            mdp.Detail.On<iOS>().SetPrefersStatusBarHidden(
                Xamarin.Forms.PlatformConfiguration.iOSSpecific.StatusBarHiddenMode.False);

            MainPage = mdp;
        }
    }
}
Comment 3 Chris King 2017-03-16 20:15:42 UTC
Closing now but if team decides to change the default I'll add a note here.
Comment 4 Michael Rumpler 2017-03-17 16:38:52 UTC
I tried that in the sample app with XF 2.3.4.214-pre5, but the result is still the same as before. No matter whether I set StatusBarHiddenMode.False, True or Default.

Even if it would work like this, I still consider this a bug. But if there's a workaround, then be it.
Comment 5 Chris King 2017-03-17 22:19:00 UTC
Thanks for re-opening. Try this:

((NavigationPage)mdp.Detail).CurrentPage.On<iOS>().SetPrefersStatusBarHidden(Xamarin.Forms.PlatformConfiguration.iOSSpecific.StatusBarHiddenMode.False);

The bit needs to be set on the ContentPage and not the NavigationPage.

And your right, it's still a bug that'll be fixed by this PR: 

https://github.com/xamarin/Xamarin.Forms/pull/822
Comment 6 Rui Marinho 2017-03-18 19:03:28 UTC
Should be fixed on 2.3.5-pre1
Comment 7 Rui Marinho 2017-03-18 19:04:30 UTC
Sorry, 2.3.4-pre6
Comment 8 Vicente Guzman 2017-10-13 14:00:25 UTC
Hi, 

I have a issue with the MasterBehavior.Popover on iOS, the left menu does not look like on Android, I wish that the animation will be the same.

Someone have any idea? I have X.F 2.4

public class RootPage : MasterDetailPage
  {
public RootPage()
    {
      switch (Device.RuntimePlatform)
      {
        case Device.iOS:
          MasterBehavior = MasterBehavior.Popover;

          break;

        default:
          MasterBehavior = MasterBehavior.Popover;
          break;
}
}

Note You need to log in before you can comment on or make changes to this bug.