标签: uisearchdisplaycontroller

UISearchBar动画隐藏按钮

我目前有一个UISearchBar(附加到UISearchDisplayController),但我缩小了搜索栏的宽度,以便在未选择搜索栏时可以在其右侧显示自定义按钮.该按钮用于访问其他视图.

但是,当我选择搜索栏然后按取消(甚至执行搜索)并返回普通视图时,搜索栏应显示我的自定义按钮,搜索栏会动画并占用所有空间按钮和不显示.从本质上讲,当我只希望它占据屏幕的一部分时,搜索栏会占用屏幕的所有宽度.

有没有办法阻止搜索栏动画到屏幕的整个宽度?

这就是我定义搜索栏的CGRect的方式:

self = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 250.0f, 45.0f)]
Run Code Online (Sandbox Code Playgroud)

iphone animation uisearchbar uisearchdisplaycontroller

6
推荐指数
1
解决办法
2483
查看次数

UISearchDisplayController自动创建一个UIPopovercontroller来显示内容搜索结果?!怎么解雇呢?

我正在使用带有UISearchBar的UISearchDisplayController.我把这个UISearchBar放在我的应用程序中使用IB,我得到:

alt text http://img6.imageshack.us/img6/1985/screenshot20100701at156.png

好的:当你开始录音时,结果popovercontroller显得神奇(我自己没有写任何东西让它出现!)

然后,当在结果中单击一行时,我想在此阶段忽略PopoverController BUT,我从未在我身边实例化过UIPopoverController:看起来如果有一个封装的行为,__CODE__它会自动将其__CODE__内部包裹起来__CODE__.这真的很棒,因为除了我无法获取对此UIPopoverController的引用以解除它之外,一切都能正常工作而不做任何事情:(

有谁知道如何获得对这个"神奇"创建的UIPopoverController的引用? (这证明iPad真的是一个"神奇"设备;)

我以为它的contentController会引用UIPopoverController(例如通过它的父属性),但我找不到任何方法来获取它的指针:/

uisearchbar uisearchdisplaycontroller ipad uipopovercontroller

6
推荐指数
1
解决办法
5621
查看次数

UISearchDisplayController"无结果"文本

可能重复:
如何在UISearchDisplayController的UISearchBar中更改"取消"按钮,"无结果"标签的字符串?

在我的UISearchDisplayController中,我想更改没有结果可用时出现在searchResultsTableView中的"无结果"文本的字体.

我怎样才能做到这一点?

iphone uisearchdisplaycontroller ios

6
推荐指数
1
解决办法
5559
查看次数

搜索栏和搜索显示控制器之间的差异

搜索栏和搜索显示控制器之间有什么区别?我什么时候应该使用其中一种?

cocoa-touch uisearchbar uisearchdisplaycontroller

6
推荐指数
0
解决办法
1117
查看次数

无法关闭"搜索"视图

我有一个带有tableview和searchbar的父类,它是tableview控制器的子类.searchBar和searchdisplaycontroller的代理设置在从UISearchdisplaycontroller继承的单独类中.tableview和searchbar的数据源和委托分别在此类中处理.这些课程属于ARC.

因此,当用户点击搜索时,控件从FilesListController(父)类转移到此类.现在,当用户点击取消按钮时,搜索栏委托在此类中设置即

- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar  
Run Code Online (Sandbox Code Playgroud)

已被调用,但不用于解除全屏搜索表视图并返回到parentviewcontroller.但是,如果我不在搜索类中编写此委托,则它可以正常工作.我已经在xib和调用中设置了搜索栏委托:

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
Run Code Online (Sandbox Code Playgroud)

像这样:

self.searchResultsTableView.delegate = self;
self.searchResultsTableView.dataSource = self;
[parentFileViewController.searchDisplayController setDelegate:self];
Run Code Online (Sandbox Code Playgroud)

我哪里错了?提前致谢.

objective-c uitableview uisearchbar uisearchdisplaycontroller ios

6
推荐指数
1
解决办法
3316
查看次数

iOS - 使用UISearchDisplayController和UISearchBar,它是UIToolbar中的UIBarButtonItem

有没有人尝试使用UISearchDisplayController和UISearchBar,它是UIToolbar中的UIBarButtonItem?

我会很感激如何成功地做到这一点.

目前,每当搜索控制器弹出时,它会重绘UISearchBar,我很难保持与UIToolbar相似的外观

uitoolbar uisearchbar uisearchdisplaycontroller ios

6
推荐指数
1
解决办法
4498
查看次数

NSCompoundPredicate

我正在尝试UITableView's使用UISearchDisplayController和过滤数据NSCompoundPredicate.我有一个3的自定义单元格UILabels,我想在搜索中过滤所有内容,因此NSCompoundPredicate.

  // Filter the array using NSPredicate(s)

  NSPredicate *predicateName = [NSPredicate predicateWithFormat:@"SELF.productName contains[c] %@", searchText];
  NSPredicate *predicateManufacturer = [NSPredicate predicateWithFormat:@"SELF.productManufacturer contains[c] %@", searchText];
  NSPredicate *predicateNumber = [NSPredicate predicateWithFormat:@"SELF.numberOfDocuments contains[c] %@",searchText];

  // Add the predicates to the NSArray

  NSArray *subPredicates = [[NSArray alloc] initWithObjects:predicateName, predicateManufacturer, predicateNumber, nil];

  NSCompoundPredicate *compoundPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:subPredicates];
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时,编译器警告我:

不兼容的指针类型使用"NSPredicate*"类型的表达式初始化"NSCompoundPredicate*_strong"

我在网上看到的每个例子都是完全相同的,所以我很困惑.该NSCompoundPredicate orPredicateWithSubpredicates:方法采用(NSArray *)最后一个参数,所以我真的很困惑.

怎么了?

objective-c uisearchbar uisearchdisplaycontroller nscompoundpredicate

6
推荐指数
2
解决办法
7360
查看次数

UISearchBar和/或UISearchDisplayController颜色

更新:感谢所有答案.我想补充一点,所使用的搜索栏实际上是UISearchBar嵌入式的,因为它的一部分UISearchDisplayController设置为a UITableView的标题.

我在这里创建了一个展示此行为的示例项目:https://dl.dropboxusercontent.com/u/3497087/TestSearchDisplayController.zip.我尝试将其设置barTintColor为蓝色和黑色.最明显的是,当设置为黑色时,我会得到一个灰色条.

我感谢所有的答案和想法,谢谢.


我正在为我正在处理的应用程序设置皮肤,我似乎遇到了带有UISearchBar和/或UISearchDisplayController条形颜色的障碍.

第一个问题我必须围绕设定barTintColorUISearchBar是连接的tableview header.我在Interface Builder中将它设置为blackColor.然而,当应用程序运行时,颜色似乎不是黑色,而是某种灰色,上面有一条丑陋的白线!我试过设置这个代码,但这似乎也没有帮助.请参阅下面的截图.

UISearchBar barTintColor在IB中设置为黑色

在模拟器上运行时,UISearchBar barTintColor

我的第二个问题围绕着UISearchDisplayController.当搜索显示控制器占据屏幕顶部时,我想要黑色.我已经尝试过设置颜色代码了,但是它唯一不会采用的颜色是黑色!

objective-c uisearchbar uisearchdisplaycontroller ios

6
推荐指数
2
解决办法
9741
查看次数

UISearchBar的范围栏未在iOS 7中显示?

我正在创建一个UISearchViewController,我希望将其放入UISearchBar导航控制器的导航项目中.这是我如何做到没有结果:

self.searchBar = [UISearchBar new];
self.searchBar.showsScopeBar = YES;
self.searchBar.scopeButtonTitles = @[@"Users", @"Hashtags"];
self.searchBar.delegate = self;

self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
self.searchController.delegate = self;
self.searchController.searchResultsDataSource = self;
self.searchController.searchResultsDelegate = self;
self.searchController.displaysSearchBarInNavigationBar = YES;
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

self.searchDisplayController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
self.searchDisplayController.searchBar.scopeButtonTitles = @[@"Users", @"Hashtags"];
self.searchDisplayController.searchBar.showsScopeBar = YES;
Run Code Online (Sandbox Code Playgroud)

我错过了什么或做错了吗?

编辑:正是我的目标.

iphone objective-c uisearchbar uisearchdisplaycontroller ios

6
推荐指数
1
解决办法
4171
查看次数

如何通过 UIsearchController 方法替换 SearchDisplayController(在 IOS 8 中已弃用)

我显然还是 Xcode 的新手。所以SeacrhDisplayController在 iOS 8 中已弃用,我不知道如何UIsearchController在 tableview上实现。

我用谷歌搜索过它,但我没有看到任何特定或明确的教程。

这是我的代码SearchDisplayController

-(BOOL)searchDisplayController:(UISearchDisplayController *)controller
    shouldReloadTableForSearchString:(NSString *)searchString
    {
        [self filterContentForSearchText:searchString
                                   scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
                                          objectAtIndex:[self.searchDisplayController.searchBar
                                                         selectedScopeButtonIndex]]];

        return YES;
    }


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.searchDisplayController.searchResultsTableView) {
        return [searchResults count];

    } else {
        return [categories count];
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @"FirstTableCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }
    if …
Run Code Online (Sandbox Code Playgroud)

uisearchbar uisearchdisplaycontroller uisearchcontroller

6
推荐指数
3
解决办法
9336
查看次数