1

我在 Elements Pack(此处)中的 MonotouchDialog 中使用 SimpleMultilineEntryElement。

无论高度设置如何,此元素都会继续出现在“默认”表格单元格高度处。实际的可编辑部分有所不同,但背景单元格轮廓没有。许多浏览表明需要实现 SizingSource,我已经做到了。所以,使用一个非常脆弱的解决方法,我现在可以有选择地调整单元格的大小。在 Root 元素上使用 UnevenRows 属性没有帮助。试图获取该索引处的单元格会杀死应用程序,即使肯定会返回索引。

  • 有没有办法让它使用我为 Multiline entryelement 定义的高度属性?

    使用系统;使用 System.Drawing;使用 MonoTouch.Dialog;使用 MonoTouch.Foundation;使用 MonoTouch.UIKit;使用元素包;使用 System.Collections.Generic;

    namespace MyNameSpace { // 编辑现有项目,如果不存在则添加一个

    公共部分类 ProjectEdit : DialogViewController { Project _p; UINavigationController _nc;

    public ProjectEdit (Project p, UINavigationController nc) : base(null, true)
    {
        _p = p;
        _nc = nc;
    
        if (_p == null)
        {
            _p = new Project();
            _p.InitialiseProjectDefaults();
        }
    
    }
    
    public override Source CreateSizingSource (bool unevenRows)
    {
        //if (unevenRows)
        {
            return new unevenSizingSource(this);
        }
    }
    
    public class unevenSizingSource : DialogViewController.SizingSource
    {
        public unevenSizingSource(DialogViewController vc) : base (vc)
        {
    
        }
    
        public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
        {
            // workaround to resize selectively
    
            // location
            if (indexPath.Section == 1 && indexPath.Row == 0)
            {
                return 200;
            }
            // description
            if (indexPath.Section == 2 && indexPath.Row == 0)
            {
                return 200;
            }
    
            return 200;
        }
    }
    
    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
    
    
    }
    
    public override void ViewWillAppear (bool animated)
    {
        base.ViewWillAppear (animated);
    
        // Client selection
        ClientListViewController cl = new ClientListViewController(_nc, _p);
    
        var basicDetailsSection = new Section("Client") {
            new StringElement(_p.ClientDisplayName, delegate { _nc.PushViewController(cl, true); })
            //new UIViewElement ("", new GapElement (), true)
        };
    
        var locationSection = new Section("Location") {
            new SimpleMultilineEntryElement ("", "This is the\n location.") { Editable = true, Height = 200,  } 
        };
    
        var descSection = new Section ("Job Description"){
            new SimpleMultilineEntryElement ("", "This is the\n description") { Editable = true, Height = 200 } 
        };
    
        Root = new RootElement ("Project Details") {
            basicDetailsSection, locationSection, descSection
        };
    
    }
    

    }

}

4

1 回答 1

3

您必须在视图出现之前设置 Root.UnevenRows。控制器示例 -

using System;
using MonoTouch.Dialog;
using ElementPack;

namespace Test1
{
    public class Test2ViewController : DialogViewController
    {
        public Test2ViewController (): base(new RootElement("test"))
        {
            Root.UnevenRows = false;

            Root.Add (new Section () 
                      {
                        new SimpleMultilineEntryElement(string.Empty, "value")
                        {
                            Height = 150, Editable = true
                        },
                        new SimpleMultilineEntryElement(string.Empty, "value2")
                        {
                            Height = 250, Editable = true
                        }});
        }
    }
}
于 2013-01-10T07:42:55.070 回答