【发布时间】:2017-08-18 10:03:08
【问题描述】:
我已经为 iOS 设备的 Objective C 中的 searchBar 编写了代码,它在 iPhone 上运行良好,但是在 iPad 上它正在改变它的 x 值,因此取消按钮也被隐藏了。
最初的搜索栏看起来像:
点击搜索栏后:
有没有人遇到这个问题并在这方面给我一些建议?
代码如下:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchBar.delegate = self;
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
followTableView.tableHeaderView = self.searchController.searchBar;
UISearchBar.appearance.tintColor = [UIColor whiteColor]; //Cancel button color
[self.searchController.searchBar sizeToFit];
tapGesture = [[UITapGestureRecognizer alloc]init];
[tapGesture addTarget:self action:@selector(tapGestureBtnAction:)];
self.searchController.searchBar.barTintColor = searchBarColor;
-(IBAction)tapGestureBtnAction:(id)sender
{
[_searchController.searchBar resignFirstResponder];
[self.view removeGestureRecognizer:tapGesture];
}
提前致谢。
【问题讨论】:
-
显示“tapGestureBtnAction”的代码
-
已更新。请检查
-
请为此发布完整代码。然后我们会得到一些东西。提前致谢。
标签: ios objective-c ipad uisearchbar uisearchcontroller