Ios 无法在searchController的搜索栏上停止动画并隐藏取消按钮

Ios 无法在searchController的搜索栏上停止动画并隐藏取消按钮,ios,navigationbar,navigationcontroller,searchbar,Ios,Navigationbar,Navigationcontroller,Searchbar,我在导航栏中设置了搜索栏。激活后,它将设置动画并显示“取消”按钮。我正在尝试停止动画并阻止“取消”按钮出现。我的故事板是在navigationController中设置的tableviewController self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil]; self.searchController.searchResultsUpdater = self; self.

我在导航栏中设置了搜索栏。激活后,它将设置动画并显示“取消”按钮。我正在尝试停止动画并阻止“取消”按钮出现。我的故事板是在navigationController中设置的tableviewController

self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;

self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0);

self.navigationItem.titleView = self.searchController.searchBar;
[self.searchController.searchBar setShowsCancelButton:NO animated:NO];

请尝试
[self.searchController.searchBar showCancelButton:NO]

不走运,我得到的是“UISearchBar”没有可见的@interface声明选择器“showCancelButton”。我的错误。它是一个属性,所以应该是
[self.searchController.searchBar setshowcancelbutton:NO]
self.searchController.searchBar.showsCancelButton=NO;