问题
I have created a view using MonoTouch.Dialog with a couple of sections. The sections require an image to be added before the other sections, however I am struggling to add the UIImage to the area before the first Section.
How would I go about this? I have highlighted where in the RootElement I would like the Image to go.
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"); })
}
};
}
回答1:
This sounds like the Headers and Footers from MonoTouch's Sample. Basically each Section
you add has HeaderView
property that you can set.
Your UIImageView
could be assigned to this property which would insert your logo in the section.
E.g. (copy/pasted from DemoHeaderFooters.cs)
var section = new Section () {
HeaderView = new UIImageView (UIImage.FromFile ("caltemplate.png")),
};
Then you use this section in your code:
return new RootElement("iEngage"){
section,
new Section("")
{
new StyledStringElement ("Search", delegate{ Console.Write("Clicked"); })
}
};
来源:https://stackoverflow.com/questions/8424847/adding-an-image-to-a-section-in-monotouch-dialog