将图像添加到 Monotouch.Dialog 中的部分 [英] Adding an image to a Section in Monotouch.Dialog

查看:26
本文介绍了将图像添加到 Monotouch.Dialog 中的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 MonoTouch.Dialog 创建了一个包含几个部分的视图.这些部分需要在其他部分之前添加一个图像,但是我正在努力将 UIImage 添加到第一部分之前的区域.

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.

我该怎么做?我已经突出显示了我希望图像在 RootElement 中的哪个位置.

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"); })
            }
        };
    }

推荐答案

这听起来像 MonoTouch 的 示例 中的 页眉和页脚.基本上,您添加的每个 Section 都有您可以设置的 HeaderView 属性.

This sounds like the Headers and Footers from MonoTouch's Sample. Basically each Section you add has HeaderView property that you can set.

您的 UIImageView 可以分配给这个属性,这将在该部分插入您的 徽标.

Your UIImageView could be assigned to this property which would insert your logo in the section.

例如(复制/粘贴自 DemoHeaderFooters.cs)>

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"); })
        }
    };

这篇关于将图像添加到 Monotouch.Dialog 中的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆