Xamarin and ios 10 - All Pages moved up behind Title Bar

允我心安 提交于 2019-12-06 14:21:46

问题


I have recently updated to ios 10 and all of my Xamarin pages and have been bumped up behind the title bar. Also the bottom of the page now does not touch the screen, it has also been bumped up.

This has happened not just for local projects, but also for an App I have already published in the App store!

The pages are bumped up around 200px or the height of the title bar.

Does anyone know of anything I can do for this???!?


回答1:


To fix this issue, update to the latest version of the Xamarin Forms Nuget Package. To do this right click on your solution in Xamarin Studio and click Update Nuget Packages. This will update all of your NuGet Packages including the Xamarin.Forms nuget package, and will fix this issue.

Note that just installing the latest version of Xamarin Studio will not fix this, you must manually update the Nuget Packages!

Credit goes to @Scott for his help!!!




回答2:


I had the same issue in my Xamarin.Forms app. What I had to do was set the NavigationBar translucent property to false through a custom renderer. If you're not using Forms, you can set this value in the ViewController itself.

        var navBar = this.NavigationController?.NavigationBar;
        if (navBar != null)
        {
            navBar.Translucent = false;
        }

Again, if you're not using forms, try setting the navigation bar's translucent property to false in the ViewController, or Storyboard.

I will say though, that for Forms, this was only required on older versions of Xamarin.Forms, and the latest version fixes this itself.

Edit: Quick (untested) Content Page renderer that should resolve this issue

using TestApp.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly:ExportRenderer(typeof(ContentPage), typeof(ContentPageRenderer))]
namespace TestApp.iOS
{
    public class ContentPageRenderer : PageRenderer
    {
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var navBar = this.NavigationController?.NavigationBar;
            if (navBar != null)
            {
                navBar.Translucent = false;
            }
        }
    }
}


来源:https://stackoverflow.com/questions/39575288/xamarin-and-ios-10-all-pages-moved-up-behind-title-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!