我将EntryElement子类化,并在GetCell方法中设置了UILineBreakMode
:
public class EntryElementEnhanced : EntryElement, IElementSizing
{
public EntryElementEnhanced(string caption, string placeholder, string value) : base (caption, placeholder, value) {}
public float GetHeight(UITableView view, NSIndexPath indexPath)
{
return 100.0f; //arbitrary number just for testing
}
public override UITableViewCell GetCell (UITableView tv)
{
var cell = base.GetCell (tv);
cell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap;
cell.TextLabel.Lines = 0;
return cell;
}
}
这似乎不会使输入单元格的文本被包装。我应该把它放在其他地方吗?
如果有人知道更好的方法,我想在更高层次上完成的是我想在MonoTouch.Dialog中创建相当于UITextArea。
答案 0 :(得分:5)
EntryElement
创建UITextField
,这是一个一个行only控件。
如果您需要多行,我建议您创建自己的Element
,例如MultilineEntryElement
,并让它在内部使用UITextView
。
您可以通过从EntryElement
复制粘贴代码或继承UIViewElement
(或两者兼而有之)来执行此操作。
答案 1 :(得分:4)
https://gist.github.com/315408
处有一个multilineEntryElement代码段在我的应用程序中它看起来有点时髦但它确实有用。
答案 2 :(得分:2)
我通过在https://gist.github.com/4080025
继承UIViewElement创建了一个MultilineEntryElement工作得很好并处理占位符。您需要根据特定宽度更新它。
答案 3 :(得分:2)
我会把帽子扔进戒指。我看了几个多行入口元素列表,他们都有布局问题。我写了这个https://gist.github.com/akcoder/5723722来解决布局问题并处理方向更改。这适用于所有版本的iPhone和iPad。