【发布时间】:2016-04-22 01:11:28
【问题描述】:
我正在使用 UISearchController,它工作正常。然而,它在搜索栏上留下了一个空白区域(当它被聚焦时),它部分隐藏了状态栏。 This espace
我已经尝试设置self.edgesForExtendedLayout = UIRectEdgeNone 和self.navigationController.extendedLayoutIncludesOpaqueBars = YES,但空间仍然存在。我尝试设置self.definesPresentationContext = YES;,但它生成了searchBar 占据状态栏位置like this。
我正在使用嵌入在UINavigationController 中的UIViewController。这是我现在实施的设置:
@interface DirectoryViewController : UIViewController <UITableViewDataSource , UITableViewDelegate ,UISearchBarDelegate, UISearchControllerDelegate, UISearchResultsUpdating>
@property (strong, nonatomic) NSMutableArray *personsArray;
@property (nonatomic, strong) UISearchController *searchController;
@property (nonatomic, strong) NSMutableArray *searchResults;
@implementation DirectoryViewController
- (void)viewDidLoad {
[super viewDidLoad];
UINavigationController *searchResultsController = [[self storyboard] instantiateViewControllerWithIdentifier:@"TableSearchResultsNavController"];
// Our instance of UISearchController will use searchResults
self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
// The searchcontroller's searchResultsUpdater property will contain our tableView.
self.searchController.searchResultsUpdater = self;
self.searchController.delegate = self;
self.searchController.searchBar.delegate = self;
//Cancel button tint
_searchController.searchBar.tintColor = [UIColor whiteColor];
[self.searchController.searchBar setBackgroundImage:[UIImage imageNamed:@"navBar"]
forBarPosition:0
barMetrics:UIBarMetricsDefault];
if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) { /// iOS 7 or above
self.edgesForExtendedLayout = UIRectEdgeNone;
}
self.navigationController.extendedLayoutIncludesOpaqueBars = YES;
}
感谢您的帮助。谢谢
【问题讨论】:
标签: ios uisearchbar statusbar uisearchcontroller