Adding an image to a Section in Monotouch.Dialog

社会主义新天地 提交于 2020-01-02 08:18:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!