我在元素包(here)中使用MonotouchDialog中的SimpleMultilineEntryElement。
无论高度设置如何,此元素仍继续显示在“默认”表格单元格高度上。实际的可编辑部分各不相同,但背景单元格轮廓没有。很多浏览表明需要实施SizingSource,我已经做到了。因此,使用非常脆弱的解决方法,我现在可以选择性地调整细胞大小。在Root元素上使用UnevenRows属性没有帮助。试图获取该索引处的单元格会杀死该应用程序,即使索引肯定会被返回。
有没有办法让它使用我为Multiline入门元素定义的高度属性?
使用System; 使用System.Drawing; 使用MonoTouch.Dialog; 使用MonoTouch.Foundation; 使用MonoTouch.UIKit; 使用ElementPack; 使用System.Collections.Generic;
命名空间MyNameSpace { //编辑现有项目或如果不存在则添加一个
public partial class ProjectEdit:DialogViewController { 项目_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
};
}
}
}
答案 0 :(得分: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
}});
}
}
}