Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Show date picker along with done button when selecting UITextField

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 791
    Comment on it

    If we want that when we tap on a UITextField then date picker should show, so we can use following code-

     [yourTextFieldOutlet setInputView:_datePicker];// _datePicker is the DatePicker type property

    Here we want to add done button on a DatePicker and once click on it DatePicker should hide.

     UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
        toolBar.barStyle = UIBarStyleBlackOpaque;
        UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneTouched:)];
        [toolBar setItems:[NSArray arrayWithObjects:doneButton,nil]];
        _yourTextFieldOutlet.inputAccessoryView = toolBar; 
    - (void)doneTouched:(UIBarButtonItem *)sender
        // hide the picker view
        [_yourTextFieldOutlet resignFirstResponder];
        // perform some action


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: