Joyal Clifford Joyal Clifford - 5 months ago 40
Objective-C Question

Display datepicker when tapping on UISearchController (Searchbar)

I am using

UISearchController
programmatically, While tapping on
Searchbar
textField
I want to be set Date picker as inputView

@property (strong, nonatomic) UISearchController *searchController;


References for text field : iPhone display date picker on UITextField touch

But unable to able to access Search bar Textfield. Please help.

Answer

You can get search textField using following code. Write it in viewDidLoad

UITextField *searchBarTextField = [self.searchController.searchBar valueForKey:@"_searchField"];
[searchBarTextField setInputView:datePicker];

Hope this will help you

Comments