嗨,这是我的问题:
在我的AppDeleagate的 didFinishLaunchingWithOptions:方法我有一个方法[self configureUINavigationControllerStlyle]; 它配置状态栏和我的应用程序的所有导航栏外观(我的UINavigationController和UITabbarController在我的应用程序中一起工作).
-(void) configureUINavigationControllerStlyle {
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UINavigationController *navigationController = (UINavigationController *)[tabBarController.viewControllers objectAtIndex:0];
navigationController.navigationBar.translucent = NO;
[[UINavigationBar appearance] setBarTintColor: [CustomColor getAwesomeColor:@"colorBlue3_1"]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{
NSForegroundColorAttributeName : [UIColor whiteColor],
NSFontAttributeName: [UIFont fontWithName:@"AvenirNext-DemiBold" size:17.0]
}];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
Run Code Online (Sandbox Code Playgroud)
另外在我的info.plist中我设置:查看基于控制器的状态栏外观为"NO"
一切都很好,我的应用程序中的所有控制器都有蓝色背景和白色文本颜色的状态栏.但不是uisearchcontroller和uisearchresultscontroller.
我的根TableViewController看起来像这样:
https://www.dropbox.com/s/oqcozos89x9yqhg/Screen%20Shot%202014-12-11%20at%2016.21.06.jpg?dl=0
我在我的应用程序中集成了searchController和searchResultsController.逻辑运行良好,但我不明白如何处理searchController和searchResultController中的状态栏外观.他们不使用我在AppDelegate.m文件中创建的状态栏的样式.
我的searchController和searchResultsController看起来像这样(状态栏变为白色,状态栏的文本颜色也变为白色,但我需要我的状态栏与我的主视图控制器中的颜色相同(蓝色背景和白色文本颜色).
https://www.dropbox.com/s/26skdz7gvehmwl4/Screen%20Shot%202014-12-11%20at%2016.21.16.png?dl=0
另一个错误:当我使用时
navigationController.navigationBar.translucent = NO;
Run Code Online (Sandbox Code Playgroud)
在我的AppDelegate中 - 在使用搜索控制器后从详细视图控制器返回时,它会导致我的家庭桌面视图"跳跃或拉伸".当我没有设置半透明属性时 - 没有"跳跃".
也许有人知道如何在iOS 8中使用searchController时修复状态栏颜色问题.
如果我使用默认颜色(不要对我的AppDelegate添加任何更改),一切正常,但我需要在我的应用程序中自定义状态栏颜色.
uistatusbar uisearchresultscontroller appdelegate ios8 uisearchcontroller
我在UITableView中的Container视图中使用UISearchController.我正在添加这样的搜索栏:
self.resultsTableController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([ResultViewController class])];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:self.resultsTableController];
self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0);
self.searchController.searchResultsUpdater = self;
[self.searchController.searchBar sizeToFit];
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.tableView.tableHeaderView = self.searchController.searchBar;
self.resultsTableController.tableView.delegate = self;
self.searchController.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = YES;
self.searchController.searchBar.delegate = self;
self.definesPresentationContext = NO;
Run Code Online (Sandbox Code Playgroud)
请参阅以下屏幕截图.它隐藏了搜索栏上方的所有搜索结果:

请帮帮我,为什么我得到这个?
uitableview childviewcontroller childviews ios8 uisearchcontroller
我正在尝试使用UISearchController创建搜索功能.但是,我似乎无法使其与我的团队对象一起工作.我首先创建了一个包含id,name和shortname的Team Object.然后我从一个url中检索teamData,并将Team Objects添加到一个填充到tableView中的数组中.这个tableView包含一个searchController,它假设过滤数据,但没有任何反应.
阵列
var teamArray = Array<Team>()
var filteredTableData = [String]()
Run Code Online (Sandbox Code Playgroud)
GetTeams功能
func getTeams(url: String) {
isApiCalling = true
request(.GET, url, parameters: nil)
.response { (request, response, data, error) in
if error == nil {
let data: AnyObject = data!
let jsonArray = JSON(data: data as! NSData)
for (key: String, subJson: JSON) in jsonArray {
// Create an object and parse your JSON one by one to append it to your array
var newTeamObject = Team(id: subJson["id"].intValue, name: subJson["name"].stringValue, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用UISearchController在我的UITableViewController中进行搜索.对于初学者项目,我使用Apple的例子.我做了一些更改,我想在示例中使用一个类而不是你.我从代码中添加我的UISearchController.我的问题是我因为exeption而无法调用UISearchController:
2015-06-18 13:35:04.750 TableSearch[4796:77813] Warning: Attempt to present <UISearchController: 0x7fe09b719f00> on <APLMainTableViewController: 0x7fe09b50e450> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我我做错了什么吗?谢谢!
我试图隐藏UISearchController中搜索栏的"取消"按钮,但不幸的是在viewDidLoad()中设置以下内容不起作用:
override func viewDidLoad() {
super.viewDidLoad()
searchResultsTableController = UITableViewController()
searchResultsTableController.tableView.delegate = self
searchController = UISearchController(searchResultsController: searchResultsTableController)
searchController.searchResultsUpdater = self
searchController.searchBar.sizeToFit()
searchResultsView.tableHeaderView = searchController.searchBar
searchController.delegate = self
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.delegate = self
searchController.searchBar.searchBarStyle = .Minimal
searchController.searchBar.showsCancelButton = false
definesPresentationContext = true
}
Run Code Online (Sandbox Code Playgroud)
我也试过在这个委托方法中使用上面的代码:
func didPresentSearchController(searchController: UISearchController) {
searchController.searchBar.showsCancelButton = false
}
Run Code Online (Sandbox Code Playgroud)
这种方法有效但在隐藏之前会短暂显示取消按钮,这并不理想.有什么建议?
我是tvos的新手,我正在尝试实现一个UISearchController视图,在我的SearchResultsViewController中,我有两个UICollectionViews一个显示在另一个上面:

问题是当用户向下滑动以选择UICollectionView中的一个项目时,键盘不会被忽略.即使向上滑动以选择键盘也无法完全向上滚动,因此无法看到您正在键入的内容.结果视图是这样的:

理想情况下,当用户向下滑动以关注界面中的任何其他内容时,我想关闭键盘.我查看了Apple的tvos UIKit目录,他们的示例显示了一个UISearchController,它在更改焦点时解除了键盘,但我没有看到他们正在做任何不同的事情.
这是我用来点击按钮时设置我的UISearchController的代码:
@IBAction func onSearchButton(sender: AnyObject) {
guard let resultsController = storyboard?.instantiateViewControllerWithIdentifier(SearchResultsViewController.storyboardID) as? SearchResultsViewController else { fatalError("Unable to instantiate a SearchResultsViewController.") }
// Create and configure a `UISearchController`.
let searchController = UISearchController(searchResultsController: resultsController)
searchController.searchResultsUpdater = resultsController
searchController.hidesNavigationBarDuringPresentation = false
let searchPlaceholderText = NSLocalizedString("Search for a Show or Movie", comment: "")
searchController.searchBar.placeholder = searchPlaceholderText
// Present the search controller from the root view controller.
guard let rootViewController = view.window?.rootViewController else { fatalError("Unable to get root view …Run Code Online (Sandbox Code Playgroud) 目标:使搜索栏始终可见.
UISearchController我做了什么:
问题:
预期行为:
题
码:
func setupSearchController() {
searchController.searchResultsUpdater = self
self.definesPresentationContext = false
searchController.delegate = self
searchController.hidesNavigationBarDuringPresentation = true
let searchBar = searchController.searchBar
view.addSubview(searchBar)
searchBar.translatesAutoresizingMaskIntoConstraints = false
searchBar.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor).active = true
searchBar.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor).active = true
searchBar.topAnchor.constraintEqualToAnchor(topLayoutGuide.bottomAnchor).active = true
}
func presentSearchController(searchController: UISearchController) {
let searchBar = searchController.searchBar
searchBar.removeFromSuperview()
let baseView = searchController.view
baseView.addSubview(searchBar)
searchBar.leadingAnchor.constraintEqualToAnchor(baseView.leadingAnchor).active = true
searchBar.trailingAnchor.constraintEqualToAnchor(baseView.trailingAnchor).active = true
searchBar.topAnchor.constraintEqualToAnchor(searchController.topLayoutGuide.bottomAnchor).active …Run Code Online (Sandbox Code Playgroud) 当没有呈现searchController时,3d touch按预期工作并调用委托方法.但是当searchController处于活动状态时不会调用.
UISearchController的创建看起来像这样
let searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.delegate = self
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = false
Run Code Online (Sandbox Code Playgroud) 具有与已发布的相同的问题(非答案工作..),我的表是固定宽度,并且在iOS 10.x中,搜索栏(在tableviewheader中)在键入时保持相同的大小.但是在iOS 11中,它跳转到屏幕顶部并在整个宽度上伸展.尝试了所有选项;
self.definesPresentationContext = YES;
tableHeaderView.clipsToBounds = YES;
etc
Run Code Online (Sandbox Code Playgroud)
但似乎没有任何改变..它仍然跳到顶部全宽..
还有其他选择吗?
Xcode 9 GM与iOS 11(Xcode 9 GM与iOS 10.x一起运行正常)
我正在推动一个viewController,我想要一个searchBar,但搜索栏根本没有显示.下面是代码.我错过了什么吗?
var searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search here..."
definesPresentationContext = true
searchController.searchBar.delegate = self
searchController.searchBar.sizeToFit()
if #available(iOS 11.0, *) {
self.navigationItem.searchController = searchController
} else {
// Fallback on earlier versions
navigationItem.titleView = searchController.searchBar
navigationItem.titleView?.layoutSubviews()
}
Run Code Online (Sandbox Code Playgroud) ios ×7
swift ×6
uitableview ×3
ios8 ×2
3dtouch ×1
appdelegate ×1
childviews ×1
ios11 ×1
ios9 ×1
objective-c ×1
tvos ×1
uistatusbar ×1