I subclassed EntryElement and have set the UILineBreakMode
in the GetCell method as such:
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;
}
}
This does not seem to make the text that gets entered into the cell word-wrapped. Should I be setting this somewhere else?
If someone knows a better approach, what I'm trying to accomplish at a higher level is I want to create the equivalent of an UITextArea in MonoTouch.Dialog.
EntryElement
creates an UITextField
which is a one line only control.
If you need multiple lines then I suggest you to create your own Element
, e.g. MultilineEntryElement
, and have it use a UITextView
internally.
You could do this by copy-pasting code from EntryElement
or by inheriting from the UIViewElement
(or a bit of both).
there is a multilineEntryElement code piece at https://gist.github.com/315408
in my app it looks a bit funky but it works.
I created a MultilineEntryElement by subclassing UIViewElement at https://gist.github.com/4080025
Works pretty well and handles a placeholder. You will need to update it for your specific width.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With