Tag: uisearchbar

如何更改UISearchBarsearch文本颜色?

如何更改UISearchBar的文本颜色?

仅当用户拉下表格时才显示search栏

我有一个表格查看与顶部的search栏。 我的要求是当有人打开页面时不显示search栏,但是当有人滑动桌面时,search栏应该是可见的。

不能与UICollectionView使用UISearchController?

在WWDC 2014的演讲“A Look Inside Presentation Controllers”中,演示者展示了如何在UITableView中设置UISearchController。 他们通过设置searchController的searchBar框架,然后将其设置为tableView的tableHeaderView。 不幸的是,没有相当于UICollectionView的tableHeaderView。 使用UISearchDisplayController,这将很简单:创build一个UISearchBar并将其添加到自定义的UICollectionView节头中,然后使用search栏初始化UISearchDisplayController。 问题是,你不能用UISearchBar初始化一个UISearchController,或者甚至设置searchBar,因为它是一个只读属性。 我想我真正的问题是,我有什么select? 没有UISearchDisplayController或UISearchController实现search的“好”的方式吗?

更改iOS 8中的UISearchBar取消button文本

我想更改从iOS的UISearchBar中取消button的“取消”的“完成”的文本。我正在使用UISearchController。 我已经尝试了iOS 6和iOS 7的不同方法,他们不工作。 有没有人做到这一点?

如何将基于故事板的标题和CustomTableCell添加到“search栏和search显示控制器”

介绍 Mine是一个简单的项目:它由一个NavigationController,ViewController和一个“Search Bar and Search Display Controller” 我的.h文件是 #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UISearchDisplayDelegate, UITableViewDataSource, UITableViewDelegate> @end 和我的.m文件是 #import "ViewController.h" @interface ViewController () @property(nonatomic,strong)NSMutableArray *data; @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.searchDisplayController.displaysSearchBarInNavigationBar = YES; self.data=[[NSMutableArray alloc]init]; } – (void)didReceiveMemoryWarning […]

如何通过iOS中的故事板将UISearchBar添加到NavigationBar

我发现如何在iPhone的导航栏中添加search栏 (一个问题 – 一个答案:很短,所以请看看)这个问题似乎是一个优雅的答案。 我喜欢在故事板(也称为IB)中做这件事:即“从NavigationBar titleView到IB中的SearchBar创build一个出口”。 但是,我将把SearchBar放在故事板上? 这是我做的: 我丢弃了我的TableView头中的SearchBar 然后从NavigatorBar我点出口作为titleView SearchBar(唯一的select) 但是,当我运行程序时,我得到一个崩溃: terminating with uncaught exception of type NSException 。 该程序还打开了我的代码 int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([MINAppDelegate class])); } }

embedded到UISplitViewController中时,iOS11 UISearchBar在UINavigationBar中丢失

奇怪的事情似乎发生在UISplitViewController的详细视图上使用新的iOS 11的navigationItem.searchController方法。 searchBar在第一个演示文稿中部分显示为空白,然后出现在错误的UITableViewController ,但在UITableViewController的一些推送和popup之后自行更正。 我曾经把searchBar放在tableHeaderView ,但是我根据WWDC的build议更改了代码: if (@available(iOS 11.0, *)) { self.navigationItem.searchController = self.searchController; self.navigationItem.hidesSearchBarWhenScrolling = NO; } else { self.tableView.tableHeaderView = self.searchController.searchBar; } 这个例子是使用标准的示例代码( UISplitViewController默认项目和UISearchController的苹果演示为iOS 11更新(使用单个UITableViewController ))。 包含searchController的初始视图如下所示: 然后单击一个UITableView项目产生这样的: 然而,点击一个UITableView项目并返回两次 – 它看起来应该是: 和: 我试图确定为什么UISearchController的苹果示例工作,我的代码没有。 主要区别在于embedded在详细视图中的UISplitViewController中。 这意味着如果在紧凑模式下显示堆栈中有一个额外的UINavigationController 。 我发现如果我的seque避免了多余的UINavigationController – 它工作正常(但打破设备旋转)。 同样改变赛格模式允许它工作。 我注意到这是类似于这个旧的问题: UISplitViewController新的UISearchController问题与UISearchBar 我已经创build了一个演示问题的示例项目( 示例代码:searchControllerDemo ) 我很难理解发生了什么事情。 所以任何帮助将非常感激。

如何覆盖UISearchBar中的取消button

我正在使用以下方法停止取消button项目在search栏中显示。 我有一个自定义的UIButton ,我想用它来代替。 问题是,目前内置的取消button仍然显示出来。 – (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller { controller.searchBar.showsCancelButton = NO; } 谢谢你的帮助

Tableview的Plistsearch

我有Plist这已被填充tableview扩大部分..现在我想search表…下面的图像,你可以看到什么事情发生时,我search任何东西。 。 只是因为我正在search它,但需要在cellforrowatindexpathsearch结果的一些变化…. 请检查代码,让我知道如何searchplist ..应该为cellforrowatindexpath更改和noofrowsinsectionsearchplist 。 。 – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [self.mySections count]; } – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSInteger rows = 0; if ([self tableView:tableView canCollapseSection:section] || !(tableView == self.searchDisplayController.searchResultsTableView) ) { if ([expandedSections containsIndex:section] ) { NSString *key = [self.mySections objectAtIndex:section]; NSArray *dataInSection = [[self.myData objectForKey:key] objectAtIndex:0]; return [dataInSection count]; } return […]

在iOS11的tableHeaderView中使用UISearchController和UISearchBar

有没有人成功保留UISearchBar在UITableView在ios11 tableHeaderView ? iPhone X在横向上通常会出现问题: Applebuild议使用新的searchController属性: if (@available(iOS 11.0, *)) { self.navigationItem.searchController = self.searchController; self.navigationItem.hidesSearchBarWhenScrolling = NO; } else { self.tableView.tableHeaderView = self.searchController.searchBar; } 但是,这并不总是奏效。 这是一个代码示例: embedded到UISplitViewController中时,iOS11 UISearchBar在UINavigationBar中丢失 所以试图在tableHeaderView保留searchBar – 实际的第一步是应用适当的自动布局约束: if (@available(iOS 11.0, *)) { UILayoutGuide *guide = self.tableView.safeAreaLayoutGuide; searchBar.translatesAutoresizingMaskIntoConstraints = NO; [searchBar.leftAnchor constraintEqualToAnchor:guide.leftAnchor].active = YES; [searchBar.rightAnchor constraintEqualToAnchor:guide.rightAnchor].active = YES; } searchBar在显示时大小正确: 但是,当UISearchBar被激活时会出现问题: 这似乎是一个老问题。 […]