First, I have an TextField. When user click on it, DatePicker will appear (in the same textfield’s view). After user choose date, DatePicker should be disappear, and textfield should show selected date.
I have tried this code in ViewDidLoad:
txtTime.TouchDown += (sender, e) => {
UIDatePicker picker = new UIDatePicker (new RectangleF (0, 20, this.View.Bounds.Width, 10));
picker.Date = DateTime.Now;
picker.Mode = UIDatePickerMode.Time;
this.Add(picker);
txtTime.ResignFirstResponder();
};
But I have some problem:
- Can’t disable keyboard (ResignFirstResponder() doesn’t work)
- I don’t know how to handle select date even of DatePicker to set for Textbox
- The DatePicker appear without ‘close’ or ‘done’ button, so can’t return to textfield view (could I use Datepicker without actionsheet?).
How can I solve that?
In the book “Developing CSharp Apps for iPhone and iPad using MonoTouch – 2011”, chapter 7 “Standard Controls” you could see example of how to implement picking date.
Basic idea is to:
Screenshot:
Sorry for Russian locale settigs.