Tag: uisearchbar

可以从UISearchBar中删除背景或边框吗?

我想得到这样的东西: 但我无法删除原始背景(我正在使用iOS5)。 不过,苹果似乎做到了: 我怎样才能创造我想要的? 或者,没有select,我唯一的select是自定义一个UITextField? 感谢您的build议和想法! 编辑:第一次回复后,这是我得到: 有没有人如何删除白色内部背景,而不使所有组件半透明改变其alpha值? 顺便说一句,我可以改变黑色的白色?

UISearchBar在开始编辑时拉伸文本

我有一个UISearchBar的实例添加到UINavigationBar的标题视图。 当文本已经被设置,并且search栏开始编辑时,它调整其内容以允许取消button的空间,但是最终的animation延伸文本,如下面的gif所示 有什么可以做的,以避免这种缺陷的影响? 我试图删除文本,然后稍后添加它,虽然它的作品,它不是一个优雅的解决scheme。 更新 基于@ Paruru的回答,我试图预测Cancelbutton的animation,它看起来不错。 我所做的就是强制在searchBarShouldBeginEditing:上searchBarShouldBeginEditing: CancelbuttonsearchBarShouldBeginEditing: extension SearchViewController: UISearchBarDelegate { func searchBarShouldBeginEditing(searchBar: UISearchBar) -> Bool { if searchBar.text?.isEmpty == false { // This avoids the text being stretched by the UISearchBar. searchBar.setShowsCancelButton(true, animated: true) } return true } } 最终的结果是我想要实现的animation,没有文本被拉伸。 我认为这是一个解决方法,所以我会等待其他答案,因为这个代码可能不是未来的证据。

在ios中过滤数组检查多个属性

我有一个自定义对象的数组。 自定义对象看起来像这样 @interface User : NSObject @property(nonatomic, strong)NSString *user_Id; @property(nonatomic, strong)NSString *user_Name; @property(nonatomic, strong)NSString *user_UserName; @end 我必须过滤数组检查2个属性。 user_Name如果我searcha然后它应该得到从数组过滤的用户列表包含a在user_Name或user_Id我怎么能做到这一点? 对于我知道的单个媒体资源[user_Name] NSString *predicateString = @"user_Name MATCHES[c] %@"; NSString *matchString = [NSString stringWithFormat: @".*%@.*",searchText]; NSPredicate *predicate =[NSPredicate predicateWithFormat:predicateString, matchString]; self.searchResults = [userArray filteredArrayUsingPredicate:predicate];

UITearchBar UITableView奇怪的抵消问题

我有一个UITableView有一个UISearchBar子视图。 这是一个UIViewController和其他一些子视图(标签,文本字段等)的视图。 表格的search栏和内容偏移量performance得相当奇怪,但它依赖于这些视图添加到xib主视图的顺序。 我创build了一个示例项目,只有我的表/search和一个标签为了testing,结果是一样的。 当表格添加在标签后面时 ,一切正常。 build立: 正确和预期的结果: 然而 ,如果我只是改变了我的2个子视图在主视图上的顺序(也就是在标签之前添加的表),那么奇怪的事情就开始发生了。 显然不好的设置: search栏奇怪的偏移量: 我什么也没有改变,所以为什么Xcode似乎关心这些子视图添加到主视图的顺序? 如果向上滚动“坏”表格设置,search栏会立即在其顶部边缘消失,但表格内容将继续向上滚动,直到到达xib中设置的帧的顶部。 向下滚动,search栏不会再出现,直到奇怪的降低位置。 这是在Xcode 5.1.1,而不是新的testing版。 Autolayout打开或不打开的结果是相同的。 任何想法为什么发生这种情况? 这是一个错误,还是我错过了什么? (我没有发布任何代码,因为我所做的只是设置段数,行数,并设置单元格的文本,而不是搞乱内容的插入,偏移,任何东西。我加载视图从应用程序委托导航控制器的根目录)

UISearchController使控制器变黑

我在iOS 8中使用UISearchController,在tab控制器中embedded视图控制器的viewDidLoad中具有以下intializiton _searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; _searchBar = _searchController.searchBar; [_searchController.searchBar sizeToFit]; _searchController.searchBar.delegate = self; _searchController.searchResultsUpdater = self; _searchController.dimsBackgroundDuringPresentation = NO; _searchController.hidesNavigationBarDuringPresentation = NO; self.definesPresentationContext = NO; _shopsTable.tableHeaderView = _searchController.searchBar; 我已经实施 – (void) updateSearchResultsForSearchController:(UISearchController *)searchController和(void)filterContentForSearchText:(NSString *)searchText 和search工作,tableview得到适当更新,等等。 但! 如果我在search控制器处于活动状态时切换标签页(只是点击search栏或一些文本)到另一个标签页,然后返回到search标签页,那么只有search栏会出现空白屏幕,如下所示 在这种情况下,我search以lar开头的东西,返回结果并正确显示。 但是,如果我切换标签,并返回到search选项卡我得到这样一个空白的屏幕。 控制器返回到原始状态的唯一方法是如果我做_searchController.active = NO 。 但是,如果用户想要保持search活跃,我不能只是停用它。 我相信我失去了一些东西,但由于在UISeachController没有太多的事情,我不知道是什么原因造成的。

UISearchBar – 什么是“search结果button”?

(重复这个问题 ,但我想我可以再试一次,因为那个没有回答…) iPhone上的UISearchBar有一个选项showsSearchResultsButton。 打开它时,它会在search栏中显示一个水平线的button,您可以实现一个callback,当用户按下该callback时将会被调用。 事情是,我无法在互联网上find一个地方,它说明了这个button的目的是什么。 我知道我可以做任何事情,但我想知道它是什么。 它应该显示一个search历史,或所有项目没有过滤,或什么?

如何以编程方式设置iOS 6/7 Deltas

当我离开iOS6时,我正在使用Xcode 4.6开发UISplitView应用程序我有devise: 现在我转移到新的Xcode5,现在我有这样的devise: UINavigationBar完全重叠我的UISearchBar … 利奥纳坦告诉我有关使用iOS 6/7 Deltas,但由于我正在创build和以编程方式添加我的UISplitViewControllers, 这可能不起作用我需要以编程方式设置iOS 6/7,但我不知道如何,我会感激任何帮助

带有UISearchDisplayController的UISearchBar在屏幕外animation

我有标准的iPad视图控制器,其顶部有一个自定义的导航栏。 在xib文件中,我添加了一个与视图右边缘alignment的UISearchBar。 search栏的宽度是320px。 我像这样初始化一个searchdisplaycontroller: // Search display controller self.mySearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:_searchBar contentsController:self]; _mySearchDisplayController.delegate = self; _mySearchDisplayController.searchResultsDataSource = self; _mySearchDisplayController.searchResultsDelegate = self; 问题是,当我按下search栏,栏调整为整个视图的整个宽度,但保持其x位置。 这意味着它延伸到屏幕之外。 我猜测它与在search栏旁边滑动的“取消”button有关。 如果将search栏放在屏幕的最左侧,则会将其移动到屏幕的整个宽度,并可以看到取消button。 任何人都有这个解决scheme?

如何在search栏中更改边框和图标(Swift)

我有这个: http://postimg.org/image/ag29m3e7d/ 我需要这个 http://postimg.org/image/4bacislw5/ 我必须创build边框或通过图像设置? 如何更改search图标(放大镜和X图标),或者我可以改变颜色? 抱歉的链接,但我不能在这里插入图像。

UISearchController:searchBar和scopeBar在第一个触摸事件上重叠

我正在尝试使用Apple最新的UISearchController实现一个简单的search栏。 但是,我似乎无法让它正常工作,如果我使用search栏的范围栏来获得筛选器的select。 范围栏总是显示我可以住在哪里 但在第一次触摸事件时,search栏和范围栏会重叠。 我使用Apple的TableView示例代码应用程序,但它没有改变任何东西。 – (void)viewDidLoad { [super viewDidLoad]; _resultsTableController = [[APLResultsTableController alloc] init]; _searchController = [[UISearchController alloc] initWithSearchResultsController:self.resultsTableController]; self.searchController.searchResultsUpdater = self; [self.searchController.searchBar sizeToFit]; self.searchController.searchBar.showsScopeBar = YES; [self.searchController.searchBar setScopeButtonTitles:@[@"First",@"Second"]]; self.tableView.tableHeaderView = self.searchController.searchBar; // we want to be the delegate for our filtered table so didSelectRowAtIndexPath is called for both tables self.resultsTableController.tableView.delegate = self; self.searchController.delegate […]