DialogViewController 不显示导航栏
DialogViewController not showing navigationbar
我正在像这样在 MvvmCross 视图中实例化 DialogViewController
var myDialog = new MyDialogViewController();
var navController = new UINavigationController();
controller.NavigationBar.TintColor = UIColor.Black;
controller.PushViewController(myDialog, false);
Add(controller.View);
这就是 MyDialogViewController 的样子:
public class MyDialogViewController : DialogViewController
{
public MyDialogViewController()
: base(UITableViewStyle.Grouped, new RootElement("MyRoot"), true)
{
var root = new RootElement("MyRoot") {
new Section
{
new HtmlElement("MyWebsite", https://www.mywebsite.com")
}
};
Root.Add(root);
}
}
带有 NavigationBar 的对话框显示正常,但如果我 select Html 元素 MyWebsite 显示 Webview 但没有 NavigationBar,我无法返回。
需要导航到新 window 的元素也会发生同样的事情,导航栏不会显示。
知道如何在导航到 WebView 后显示 NavigationBar 吗?
这对我有用:
var settings = new SettingsDialogViewController((SettingsViewModel)ViewModel, new RootElement("Settings"));
var window = UIApplication.SharedApplication.KeyWindow;
navigationController = window.RootViewController.ChildViewControllers[1].NavigationController;
navigationController.PushViewController(settings, true);
navigationController.NavigationBarHidden = false;
我正在像这样在 MvvmCross 视图中实例化 DialogViewController
var myDialog = new MyDialogViewController();
var navController = new UINavigationController();
controller.NavigationBar.TintColor = UIColor.Black;
controller.PushViewController(myDialog, false);
Add(controller.View);
这就是 MyDialogViewController 的样子:
public class MyDialogViewController : DialogViewController
{
public MyDialogViewController()
: base(UITableViewStyle.Grouped, new RootElement("MyRoot"), true)
{
var root = new RootElement("MyRoot") {
new Section
{
new HtmlElement("MyWebsite", https://www.mywebsite.com")
}
};
Root.Add(root);
}
}
带有 NavigationBar 的对话框显示正常,但如果我 select Html 元素 MyWebsite 显示 Webview 但没有 NavigationBar,我无法返回。
需要导航到新 window 的元素也会发生同样的事情,导航栏不会显示。
知道如何在导航到 WebView 后显示 NavigationBar 吗?
这对我有用:
var settings = new SettingsDialogViewController((SettingsViewModel)ViewModel, new RootElement("Settings"));
var window = UIApplication.SharedApplication.KeyWindow;
navigationController = window.RootViewController.ChildViewControllers[1].NavigationController;
navigationController.PushViewController(settings, true);
navigationController.NavigationBarHidden = false;