码迷,mamicode.com
首页 > 其他好文 > 详细

iPad keyboard will not dismiss if modal view controller presentation style is UIModalPresentationFor

时间:2014-08-12 00:42:23      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:ipad   keyboard   

在ipad上present 一个 navigation controller 时,present后弹出的keyboard,不能够 dismiss 掉。即使 textfield resignFirstResponder,keyboard也不会消失。

Problem:

在iPad keyboard上发现一个问题,当viewController在navigation controller下以模态视图弹出,并且navigationController.modalPresentationStyle = UIModalPresentationFormSheet时,点击done按钮,软键盘不撤销,即使 textfield resignFirstResponder了。

Solution:

当模态视图在 UINavigationControlle下显示,我们需要设置 navigation controller的disablesAutomaticKeyboardDismissal属性,我们可以通过添加类别实现这个。


File: UINavigationController+KeyboardDismiss.h

#import 

@interface UINavigationController (KeyboardDismiss)

- (BOOL)disablesAutomaticKeyboardDismissal;

@end

File: UINavigationController+KeyboardDismiss.m

#import "UINavigationController+KeyboardDismiss.h"

@implementation UINavigationController(KeyboardDismiss)

- (BOOL)disablesAutomaticKeyboardDismissal

{

    return NO;

}

@end

在需要用到的ViewController文件中导入创建的类别即可。

iPad keyboard will not dismiss if modal view controller presentation style is UIModalPresentationFor,布布扣,bubuko.com

iPad keyboard will not dismiss if modal view controller presentation style is UIModalPresentationFor

标签:ipad   keyboard   

原文地址:http://blog.csdn.net/leochang130731/article/details/38502525

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!