【发布时间】:2018-10-17 14:13:51
【问题描述】:
我有一个 Xamarin.Forms 应用程序,目前正在删除iOS 上导航栏下的行。
public partial class MainPage : TabbedPage
{
public MainPage()
{
InitializeComponent();
var homePage = new NavigationPage(new HomePage())
{
Title = "Home",
Icon = "home.png"
};
var helpPage = new NavigationPage(new HelpPage())
{
Title = "Help",
Icon = "help.png"
};
// other declarations here
Children.Add(homePage);
Children.Add(helpPage);
// and more
}
}
我在AppDelegate 中尝试过UINavigationBar.Appearance.ShadowImage = new UIImage();,但它根本不起作用,所以我创建了以下渲染器。
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(NavigationPage), typeof(Japanese.iOS.NavigationPageRenderer))]
namespace Japanese.iOS
{
public class NavigationPageRenderer : NavigationRenderer
{
public override void ViewDidLoad()
{
base.ViewDidLoad();
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
UINavigationBar.Appearance.ShadowImage = new UIImage();
}
}
}
这有效,但仅适用于HomePage,这是应用程序启动时打开的第一个页面。
【问题讨论】:
-
页面加载时是否调用 viewdidload 方法?
-
@G.hakim 它做了 5 次,这也是我拥有的标签数量
-
我说的是当您导航到帮助页面时!还是帮助页面也在同一个标签页内?
-
ViewDidLoad 方法在我第一次打开应用程序时被同时调用了 5 次。当我导航到不同的标签时,它不再被调用
-
帮助也是标签页吗?
标签: xamarin xamarin.forms xamarin.ios