Forum Xamarin.iOS

My date Picker Controller is not showing properly.

hardik.4160hardik.4160 USMember

i have used this github code for date picker https://github.com/SharpMobileCode/ModalPickerViewController

here is my code in view did load method

txtDate.EditingDidBegin+=(sender, e) => {
txtDate.EndEditing(true);
var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "Select A Date", this)
{
HeaderBackgroundColor = UIColor.Black,
HeaderTextColor = UIColor.Blue,
TransitioningDelegate = new ModalPickerTransitionDelegate(),
ModalPresentationStyle = UIModalPresentationStyle.Custom
};

        modalPicker.DatePicker.Mode = UIDatePickerMode.Date;
        modalPicker.OnModalPickerDismissed += (s, ea) => 
            {
                string selectedDate=modalPicker.DatePicker.Date.ToString();
                string date=Convert.ToDateTime(selectedDate).ToString("yyyy-MM-dd");
                txtDate.Text=date;
            };

            PresentViewControllerAsync(modalPicker, true);

        };

problem is when i move from one textfield to another txtdatefield then previous textfield's keyboard is shown instead of datepicker. the datepickerview is behind the previous textfield's keyboard.... i also tried to hide the keyboard manually by resign first responder but nothing works..
.

Best Answer

Answers

  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    Can you post a screenshot of what is happening and a small sample project that reproduces the issue?

  • hardik.4160hardik.4160 USMember

    here is the screen shot and the code of picker view i posted above
    and the datepicker code is on github as it is...

  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    Thanks! I meant an example of your code that reproduces the issue.

  • hardik.4160hardik.4160 USMember

    the code that reproduce the issue is here

    txtDate.EditingDidBegin+=(sender, e) => {
    txtDate.EndEditing(true);
    var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "Select A Date", this)
    {
    HeaderBackgroundColor = UIColor.Black,
    HeaderTextColor = UIColor.Blue,
    TransitioningDelegate = new ModalPickerTransitionDelegate(),
    ModalPresentationStyle = UIModalPresentationStyle.Custom
    };

        modalPicker.DatePicker.Mode = UIDatePickerMode.Date;
        modalPicker.OnModalPickerDismissed += (s, ea) => 
            {
                string selectedDate=modalPicker.DatePicker.Date.ToString();
                string date=Convert.ToDateTime(selectedDate).ToString("yyyy-MM-dd");
                txtDate.Text=date;
            };
    
            PresentViewControllerAsync(modalPicker, true);
    
        };
    
  • hardik.4160hardik.4160 USMember

    thanks...

Sign In or Register to comment.