9 uisplitviewcontroller ios ios8 uisearchcontroller adaptive-ui
使用具有自适应UISplitViewController用户界面的通用故事板.
我想使用以下代码(来自主视图控制器)在主(主)端提供搜索控制器:
static NSString * const kCGISearchViewControllerID = @"SearchViewControllerID";
- (IBAction)searchButtonClicked:(UIBarButtonItem *)__unused sender {
SearchViewController *searchResultsController = [self.storyboard instantiateViewControllerWithIdentifier:kCGISearchViewControllerID];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
self.searchController.searchResultsUpdater = searchResultsController;
self.searchController.hidesNavigationBarDuringPresentation = NO;
[self presentViewController:self.searchController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
它最初似乎正常工作(无论起始方向):

自动旋转后出现问题(键盘仍然可见,底层内容仍然变暗,但搜索栏已消失):

旋转回横向时,搜索栏重新出现,但其宽度现在错误:

(我也尝试将搜索控制器searchBar放入其中titleView.当searchBar正确适应时,搜索结果控制器仍然看起来不正确.)
UISearchController当UI适应不断变化的大小类时,我错过了什么才能正确地呈现动画本身?
更新:
添加self.definesPresentationContext = YES;会使搜索栏/结果显示在主视图中,但搜索栏会在该导航栏下显示动画,并且不可见.另一个问题是,当它从纵向(具有状态栏)旋转回到横向时,搜索栏高度不会缩小.
您正在使用哪个Xcode版本?模拟器上的哪个iOS版本?
尝试使用Xcode 6,iOS 8.4-这就是我在MasterVC中使用的所有代码:
class MasterViewController: UITableViewController {
@IBAction func search(sender: UIBarButtonItem) {
let searchController = UISearchController(searchResultsController: nil)
searchController.hidesNavigationBarDuringPresentation = false
presentViewController(searchController, animated: true, completion: nil)
}
...
}
Run Code Online (Sandbox Code Playgroud)
它显示在母版中,并锁定屏幕的方向!自您发布答案以来,行为可能已更改。
| 归档时间: |
|
| 查看次数: |
1890 次 |
| 最近记录: |