Section.HeaderView在Monotouch对话框中自动调整大小

时间:2012-05-08 19:44:51

标签: xamarin.ios monotouch.dialog

我正在使用Monotouch.Dialog和 我已经将类子类子类化为实现自定义HeaderView。问题是标题视图会自动调整大小,这是我正在使用的代码:

    public class MySection : Section
    {
        public MySection ()
        {
            UIView v = new UIView(new RectangleF(0,0,30,30));
            v.BackgroundColor = UIColor.Red;
            this.HeaderView = v;
        }
    }

我附上了屏幕截图:
http://imageshack.us/photo/my-images/864/capturedcran20120508212.png



EDIT

好的我有点找到解决这个问题的方法

诀窍是添加一个包含真实HeaderView的View,并将AutosizesSubviews属性设置为false。然后只需将视图添加到最新的:

    public class MySection : Section
{
    public MySection ()
    {
        UIView v0 = new UIView(new RectangleF(0,0,50, 60));
        v0.AutosizesSubviews = false;
        UIView v = new UIView(new RectangleF(0,0,30,30));
        v.BackgroundColor = UIColor.Red;
        v0.AddSubview(v);
        this.HeaderView = v0;
    }
}

0 个答案:

没有答案