Reputation: 10203
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:
How can I solve that?
Upvotes: 1
Views: 2296
Reputation: 75
this.txtTime.shouldreturn += (txtTime) => {
txtTime.resignfirstresponder ();
return true;
}
Upvotes: 0
Reputation: 2570
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.
Upvotes: 1