4

我正在使用 Monotouch.Dialog,并且我已经对类 Section 进行了子类化以实现自定义 HeaderView。问题是标题视图会自动调整大小,这是我正在使用的代码:

    公共类 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/capturdcran20120508212.png



编辑

好的,我已经找到了解决这个问题的方法

诀窍是添加一个包含真实 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;
    }
}
4

0 回答 0