Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can EntryElement be multiline on MonoTouch.Dialog?

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.

like image 510
valdetero Avatar asked Mar 12 '12 20:03

valdetero


3 Answers

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).

like image 197
poupou Avatar answered Nov 17 '22 04:11

poupou


there is a multilineEntryElement code piece at https://gist.github.com/315408

in my app it looks a bit funky but it works.

like image 41
Mr W Avatar answered Nov 17 '22 05:11

Mr W


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.

like image 2
Dave Weaver Avatar answered Nov 17 '22 05:11

Dave Weaver