ViewController有definesPresentationContext和 providesPresentationContextTransitionStyle,但没有它们是如何工作的想法.我看过WWDC2011,但我仍然对这两件事感到困惑.
任何人都可以解释一下,最好用简单的演示吗?
在我们的项目中,我们指定
hidesNavigationBarDuringPresentation = false
Run Code Online (Sandbox Code Playgroud)
在某人UIViewController的身上UISearchController。searchController具有一系列范围标题。到目前为止,它在iOS 10上都可以正常运行,但是在iOS 11 beta中,似乎hidesNavigationBarDuringPresentation的错误设置被忽略,使显示混乱。为确保不是我项目中的其他因素,我创建了一个仅有一个项目的准系统测试项目UITableViewController,并UISearchController使用另一个simple 进行了初始化UITableViewController。以下代码位于viewDidLoad()主视图控制器上的方法中:
self.title = "Search Bar Scope Test"
let searchViewController = SearchViewController(style: .plain)
searchController = UISearchController(searchResultsController: searchViewController)
searchController!.searchBar.sizeToFit()
tableView.tableHeaderView = searchController!.searchBar
searchController?.hidesNavigationBarDuringPresentation = false
searchController?.searchBar.scopeButtonTitles = ["scope 1", "scope 2", "scope 3", "scope 4", "scope 5"]
Run Code Online (Sandbox Code Playgroud)
当最后一行分配scopeButtonTitles不存在时,导航栏不会隐藏,搜索栏仍保持其原始位置。但是,在存在该行的情况下,iPhone和iPad上的都NavigationBar变为隐藏状态,searchBar加号和范围按钮在纵向模式下都向上移动,而在横向模式下保持不变(即使范围按钮很多并且不能一起使用)线)。
有人遇到过吗?这是iOS 11中的错误或预期行为(虽然不是我们的预期行为),并且有任何解决方法吗?
谢谢!