我想在Xamarin.iOS中实现弹出导航。为此我使用FlyoutNavigationController,到目前为止效果很好。
但现在我必须在弹出菜单内的导航列表下方显示一些附加内容(基本上是图片,一些标签和按钮)。为此,我想使用保存菜单项的“section”控件的FooterView属性。
当我设置
section.Footer = "Test";
它可以工作(我可以看到文字),但是当我使用'FooterView'属性时,没有任何显示:
public class ViewController : UIViewController
{
FlyoutNavigationController navigation;
private const string PageNamePage1 = "The first page";
private const string PageNamePage2 = "The second page";
readonly string[] pages =
{
PageNamePage1,
PageNamePage2
};
public override void ViewDidLoad()
{
base.ViewDidLoad();
navigation = new FlyoutNavigationController
{
View =
{
Frame = UIScreen.MainScreen.Bounds
}
};
View.AddSubview(navigation.View);
var elements = pages.Select(page => new StringElement(page) as Element);
navigation.NavigationRoot = new RootElement("Induserv App");
var section = new Section();
section.AddAll(elements);
var uiTextView = new UITextView {Text = "--> This won't show!"};
section.FooterView = new UIView
{
uiTextView
};
navigation.NavigationRoot.Add(section);
navigation.ViewControllers = new UIViewController[]
{
new UINavigationController(new Page1Controller(navigation, PageNamePage1)),
new UINavigationController(new Page2Controller(navigation, PageNamePage2)),
};
}
}
有没有人知道在这里显示这个页脚需要什么?还有另一种方法可以在这个面板中放置一些控件吗?
答案 0 :(得分:1)
为页脚视图和uiTextView设置框架,如下所示:
var uiTextView = new UITextView(new RectangleF(0, 0, 10, 10)) {Text = "--> This won't show!"};
section.FooterView = new UIView(new RectangleF(0, 0, 10, 10))
{
uiTextView
};