Tôi đang sử dụng một UISearchController và một UISearchResultsController để thực hiện chức năng tìm kiếm.Thanh tìm kiếm trùng lặp với thanh trạng thái trên iOS 11
MySearchResultsController thực hiện UISearchResultsUpdating và UISearchBarDelegate:
override open func viewDidLoad() {
super.viewDidLoad()
self.edgesForExtendedLayout = [];
self.automaticallyAdjustsScrollViewInsets = false;
}
tôi hiển thị thanh tìm kiếm trong tableHeader như thế này trong MyTableViewController:
- (void)viewDidLoad {
[super viewDidLoad];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:self.searchResultsController];
self.searchController.searchResultsUpdater = self.searchResultsController;
self.searchController.searchBar.delegate = self.searchResultsController;
self.searchController.searchBar.scopeButtonTitles = @[NSLocalizedString(@"SEARCH_SCOPE_TEMPERATURES", nil), NSLocalizedString(@"SEARCH_SCOPE_KNOWHOW", nil)];
self.tableView.tableHeaderView = self.searchController.searchBar;
self.definesPresentationContext = YES;
}
này đã làm việc một cách hoàn hảo trước đó, nhưng dưới iOS 11 thanh tìm kiếm trùng lặp với thanh trạng thái ngay sau khi tôi gõ vào nó (xem ảnh chụp màn hình). Tôi đã thử rất nhiều thứ khác nhau để làm cho nó hiển thị chính xác nhưng chưa tìm được giải pháp nào.
Tôi chỉ phát hiện ra rằng điều này không xảy ra khi tôi xóa tiêu đề nút phạm vi (mà tôi không muốn làm ...) – Stefan