Can EntryElement be multi-line in MonoTouch.Dialog?

I subclassed the EntryElement element and 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 is entered in the cell wrapped by the word. Should I install this somewhere else?

If someone knows a better approach, then what I'm trying to accomplish at a higher level, I want to create the equivalent of UITextArea in MonoTouch.Dialog.

+7
source share
4 answers

EntryElement creates a UITextField , which is a single line only .

If you need several lines, I suggest you create your own Element , for example. MultilineEntryElement , and use the UITextView inside it.

You can do this by copying code from EntryElement or inheriting from UIViewElement (or a little of both).

+5
source

there is a multi-level EntryElement code snippet at https://gist.github.com/315408

in my application it looks a bit funky, but it works.

+4
source

I created MultilineEntryElement by subclassing UIViewElement at https://gist.github.com/4080025

Works well and handles the placeholder. You will need to update it for your specific width.

+2
source

I'll throw my hat in the ring. I looked at a couple of multi-line input elements, and they all had layout problems. I wrote this https://gist.github.com/akcoder/5723722 to solve layout problems, and also to handle orientation changes. This should work on all versions of the iPhone and iPad.

+2
source

All Articles