@H_301_1@我试图在iOS7 UISearchDisplayController类中使用displaysSearchBarInNavigationBar属性来显示导航栏中的搜索栏.
使用AdvancedTableSearch example from Apple作为基础,我已将代码更改为禁用范围(导航栏中不允许),并将showsSearchBarInNavigationBar设置为true,如此.
- (void)viewDidLoad { [super viewDidLoad]; // create a mutable array to contain products for the search results table self.searchResults = [NSMutableArray arrayWithCapacity:[self.products count]]; self.searchDisplayController.displaysSearchBarInNavigationBar = YES; }
不幸的是,我得到的结果如下所示:
搜索栏出现在屏幕中间,而不是在navigationItem中.
我究竟做错了什么?
PS:我不确定它是否相关,但self.searchDisplayController.navigationItem属性为零.