UISearchController在iPad上显示全屏而不是弹出窗口 [英] UISearchController showing fullscreen instead of a popup on iPad

查看:366
本文介绍了UISearchController在iPad上显示全屏而不是弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个像地图应用程序一样的搜索控件;搜索在iPhone上打开结果tableview(工作正常),并应在iPad上的popover中打开tableview。这曾经在 UISearchDisplayController 中自动生效,但不再起作用,它在iPad上显示全屏桌面视图。

I want to build a search control like the maps app; the search opens a result tableview (which works fine) on iPhone and should open a tableview in a popover on iPad. This used to be automatic in UISearchDisplayController but does not work anymore and it shows a fullscreen tableview on iPad.

self.resultsController = [[EFResultTableViewController alloc] init];
[self.resultsController.tableView setDelegate:(id<UITableViewDelegate>)self];

self.searchController =
    [[UISearchController alloc] initWithSearchResultsController:self.resultsController];
[self.searchController setSearchResultsUpdater:(id<UISearchResultsUpdating>)self];

self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;
[self.searchController.searchBar setBarTintColor:[UIColor whiteColor]];

[self.searchController.searchBar setDelegate:(id<UISearchBarDelegate>)self];
self.definesPresentationContext = YES;

ResultTableViewController 只是一个自定义的tableview。我不想写 IS_IPAD 条件代码。这里有什么我想念的。

ResultTableViewController is just a customised tableview. I do not want to write IS_IPAD conditional code. Is there anything I am missing here.

推荐答案

解决方案非常简单,你需要在控制器上设置样式,它在iPhone上显示正常列表并在iPad上自动弹出。

THe solution was pretty simple, you need to set the style on the controller, it shows a normal list on iPhone and popover on iPad automatically.

[self.searchController setModalPresentationStyle:UIModalPresentationPopover];

这篇关于UISearchController在iPad上显示全屏而不是弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆