简体   繁体   中英

How to pop self view controller when I click the cancel button at the search bar?

I have created the search view controller to add the articles searched to the main view controller. I wanna make it to pop itself from navigation view controller by clicking the cancel button of search bar. I have tried like as below:

- (void) searchBarCancelButtonClicked:(UISearchBar*) searchBar {
  [self.navigationController popViewControllerAnimated:NO];
}

I need a help from everybody.

检查是否已将searchBar委托分配给viewController ..,还检查navigationController是否为nil,则代码应该工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM