Calling ShouldEndEditing delegate Call back when click on UISearchBar control in UIPopovercontroller

Hi team,

I am calling UISearchBar control for search then it presents the table view controller inside the UIPopovercontroller but as soon as it calls the ShouldBeginEditing delegate callback of UiSearchBar then it Automatically the ShouldEndEditing Delegate callback of UiSearchBar control.

The above scenario is happening with Xcode 10 + version. The same scenario is not happening with Xcode 8 version. Please find below the code and guide me where I am wrong. Thanks for Help.


Code:


-(BOOL)searchBarShouldBeginEditing:(UISearchBar*)searchBar

{

if([searchBar isEqual:_normalSearch_SearchBar])

{

[[KeyboardHideShow getInstance] setScrollRectToThisFrame:[searchBar convertRect:searchBar.frame toView:self.scrollView]];

if(!self->_normalSearchPopOverController)

{

[[KeyboardHideShow getInstance] setUp_With_ScrollView:nil];

[self setTableViewController:[[UITableViewController alloc] initWithStyle:UITableViewStylePlain]];

[self->_tableViewController.tableView setDelegate:self];

[self->_tableViewController.tableView setDataSource:self];

[self addTransparentView_For_NormalSearch_And_AdvancedSearch];

//To add the transparent view


[self setNormalSearchPopOverController:[[UIPopoverController alloc] initWithContentViewController:self->_tableViewController]];

[self->_normalSearchPopOverController setDelegate:self];

[self->_normalSearchPopOverController setPopoverContentSize:CGSizeMake(POPOVERWIDTH,350)];

[self->_normalSearchPopOverController presentPopoverFromBarButtonItem:self->_searchBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];


return YES;

}

}

return NO;

}

I would be a bit concerned about having these lines of code inside the shouldBeginEditing method:


           [self setTableViewController:[[UITableViewController alloc] initWithStyle:UITableViewStylePlain]];
           [self->_tableViewController.tableView setDelegate:self];
           [self->_tableViewController.tableView setDataSource:self];


           [self setNormalSearchPopOverController:[[UIPopoverController alloc] initWithContentViewController:self->_tableViewController]];
           [self->_normalSearchPopOverController setDelegate:self];

Just Added the Table View to represent the list from a response array and put it into UIPopOverController then on Action of UISeachBar control it shows as UiPopovercotroller to represent a view in iPad. So, when I click on the search bar then it calls the SholudBeginEditing after that it calls directly ShouldEndEditing Delegate callback of UISearchBAr control. Thanks for your valuable Response.

Calling ShouldEndEditing delegate Call back when click on UISearchBar control in UIPopovercontroller
 
 
Q