Note that there are some explanatory texts on larger screens.

plurals
  1. POHow display UISearchBar in UINavigation?
    primarykey
    data
    text
    <p>I have search icon in navigation bar, and UISearchBar in TableViewHeader. I want to hide UISearchBar but show and hide when:</p> <p><strong>UISearchbar show</strong>: Clicked on the search icon, then eliminate navigation and show it. </p> <p><strong>UISearchBar hide</strong>: Press cancel to hide search and display navigation back.</p> <p>Please help me!!</p> <p>Thank.</p> <p><img src="https://i.stack.imgur.com/Pptuj.jpg" alt=""></p> <p>This is what I have done so far.</p> <pre><code>- (void) viewDidload{ self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero]; self.searchBar.placeholder = @"Search"; self.searchBar.delegate = self; [self.searchBar sizeToFit]; self.strongSearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self]; self.searchDisplayController.searchResultsDataSource = self; self.searchDisplayController.searchResultsDelegate = self; self.searchDisplayController.delegate = self; self.tableView.tableHeaderView = self.searchBar; _btnSearch = [UIButton buttonWithType:UIButtonTypeCustom]; _btnSearch.frame = CGRectMake(0, 0, 22, 22); [_btnSearch setImage:[UIImage imageNamed:@"search_btn.png"] forState:UIControlStateNormal]; [_btnSearch addTarget:self action:@selector(showSearch:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithCustomView:_btnSearch]; self.navigationItem.rightBarButtonItems = _btnSearch; } </code></pre> <p>This is my action when click on the iCon search</p> <pre><code>- (IBAction)showSearch:(id)sender{ [self.searchBar becomeFirstResponder]; } </code></pre> <p>I don't want to place my search in tableView and how still I can display UISearchBar when click on search icon?</p> <p><strong>Another question:</strong> when I call [self.searchBar becomeFirstResponder]; it's doesn't work good. The cancel button doesn't work at all.</p> <p>Please kindly help me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload