public override UITableViewCell GetCell (UITableView tv)
{
_tableView = tv;
var cell = tv.DequeueReusableCell (cellkey);
if (cell == null) {
cell = new UITableViewCell (UITableViewCellStyle.Default, cellkey);
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
} else {
//RemoveTag (cell, 1);
}
cell.BackgroundColor = Appearance.BackgroundColorEditable;
if (entry == null) {
SizeF size = ComputeEntryPosition (tv, cell);
float width = cell.ContentView.Bounds.Width;
entry = CreateTextField (new RectangleF ( 0, 0, width, size.Height + (height)));
entry.Font = Appearance.LabelFont;
var toolbar = new UIToolbar();
toolbar.Items = new UIBarButtonItem[] {
new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (e, a)=>{
entry.ResignFirstResponder();
})
};
toolbar.SizeToFit();
entry.InputAccessoryView = toolbar;
entry.Font = inputFont;
entry.Changed += delegate {
FetchValue ();
};
entry.Ended += delegate {
FetchValue ();
if (OnValueChanged!=null) OnValueChanged(this);
};
// entry.ShouldReturn += delegate {
//
// if (ShouldReturn != null)
// return ShouldReturn ();
//
// RootElement root = GetImmediateRootElement ();
// EntryElement focus = null;
//
// if (root == null)
// return true;
//
// foreach (var s in root.Sections) {
// foreach (var e in s.Elements) {
// if (e == this) {
// focus = this;
// } else if (focus != null && e is EntryElement) {
// focus = e as EntryElement;
// break;
// }
// }
//
// if (focus != null && focus != this)
// break;
// }
//
// if (focus != this)
// focus.BecomeFirstResponder (true);
// else
// focus.ResignFirstResponder (true);
//
// return true;
// };
entry.Started += delegate {
entry.ReturnKeyType = UIReturnKeyType.Default;
};
}
if (becomeResponder) {
entry.BecomeFirstResponder ();
becomeResponder = false;
}
entry.KeyboardType = KeyboardType;
entry.PlaceholderText = PlaceholderText;
entry.AutocapitalizationType = AutocapitalizationType;
entry.AutocorrectionType = AutocorrectionType;
cell.TextLabel.Text = Caption;
cell.ContentView.AddSubview (entry);
return cell;
}