keyboard not responding to resignFirstResponder

前端 未结 5 723
遥遥无期
遥遥无期 2021-01-07 00:39

Instead of showing the keyboard I want to display a popover view when a textField is selected (my code is at the bottom). If the keyboard isn\'t showing then everything wor

5条回答
  •  攒了一身酷
    2021-01-07 01:23

    Try like this in your editStartDate: method

    [self.startDateTextField resignFirstResponder];
    

    EDIT: But instead of doing resign the keyboard when you click in textfield, you can make something like setInputView for Textfield to bring out the popViewController.

    DatePickerVC *datePickerVC = [[DatePickerVC alloc] init];
    datePickerVC.delegate = self;
    
    self.popoverController = [[UIPopoverController alloc] initWithContentViewController:datePickerVC];
    [self.popoverController setDelegate:self];
    
    [self.popoverController presentPopoverFromRect:CGRectMake(0, 0, 5, 5) inView:textField permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
    
     self.startDateTextField = [[UITextField alloc] initWithFrame:CGRectMake(79, 148, 138, 27)];
    [self.startDateTextField setBorderStyle:UITextBorderStyleRoundedRect];
    [self.startDateTextField setDelegate:delegate];
    self.startDateTextField.inputView = self.popoverController;
    

提交回复
热议问题