在Monotouch.Dialog中为Section添加图像
本文关键字:添加 图像 Section 中为 Monotouch Dialog | 更新日期: 2023-09-27 18:17:12
我使用MonoTouch创建了一个视图。对话框与几个部分。部分需要在其他部分之前添加图像,但是我正在努力将UIImage添加到第一个部分之前的区域。
我该怎么做呢?我已经在RootElement中突出显示了我想要图像的位置。
public void HomeScreen ()
{
var root = CreateRoot_HomeScreen ();
var dv = new DialogViewController (root, true);
navigation.PushViewController (dv, true);
}
RootElement CreateRoot_HomeScreen()
{
// Set up the ImageView with the Logo in it
var logo = UIImage.FromFile("Images/logo.png");
var imageView = new UIImageView(logo);
return new RootElement("iEngage"){
// The Image should go here
new Section(){
},
new Section("")
{
new StyledStringElement ("Search", delegate{ Console.Write("Clicked"); })
}
};
}
这听起来像MonoTouch的样本中的页眉和页脚。基本上你添加的每个Section
都有可以设置的HeaderView
属性。
你的UIImageView
可以分配给这个属性,它将在section中插入你的标志。
。(复制/粘贴自DemoHeaderFooters.cs)
var section = new Section () {
HeaderView = new UIImageView (UIImage.FromFile ("caltemplate.png")),
};
然后在你的代码中使用这个部分:
return new RootElement("iEngage"){
section,
new Section("")
{
new StyledStringElement ("Search", delegate{ Console.Write("Clicked"); })
}
};