ios - 获取 UISplitViewController 的 masterview Controller 的显示隐藏事件

标签 ios objective-c iphone ios7 ios8

我正在从事一个项目,该项目是架构中的主从架构,它是一个通用应用程序。我的 DetailViewController 导航栏中有一个搜索控件。当我开始搜索时,同时如果我滑动/点击左栏按钮以显示 MasterViewController 键盘不会消失。

我想获取 MasterviewController 的显示/隐藏事件。

最佳答案

我有解决你问题的办法
下面是一个委托(delegate)方法,当用户滑动显示或隐藏主视图时将调用该方法,您可以在其中编写隐藏键盘的代码

代码:

- (void)splitViewController:(UISplitViewController *)svc willChangeToDisplayMode:(UISplitViewControllerDisplayMode)displayMode NS_AVAILABLE_IOS(8_0)
{
    // Write code to hide keyboad
    // --------- Code is not tested but it must work ---------------------------
     [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
    // -------------------------------------------------------------------------
}


示例项目
Link

输出
有错误
enter image description here
解决bug
enter image description here

测试步骤
1] 以纵向模式打开项目。
2] 从左向右滑动以打开主视图。
3] 选择“搜索”。
4] 从详细 View 中选择“嵌入导航栏的搜索栏”。
5] 点击搜索栏。
6] 从左向右滑动以打开主视图。
7]键盘会隐藏,会显示materview。

关于ios - 获取 UISplitViewController 的 masterview Controller 的显示隐藏事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27310800/

相关文章:

ios - 捕获正在运行的视频的屏幕截图

iphone - 如何在已有的PDF中绘图?

ios - 无法在路径中打开 Realm

iOS UIWebView 捕获用户点击文本输入

ios - 带预览的分页 UIImages

ios - CS193P 作业3,Graphing MVC 的模型应该是什么?

ios - 为什么使用 HTML 字符串对 NSAttributedString 的初始调用比后续调用要长 100 多倍?

objective-c - 来自 ios 中位置服务的多个位置?

iphone - 如何打印出UInt16指向NSLog的指针

iphone - 移除 TabBarItem 突出显示