Keyboard hide and show again right after UIActionSheet dismiss in iOS 7, SDK 7

与世无争的帅哥 提交于 2019-11-30 05:01:12

There is a very simple solution. One should add private local category in .m file of the controller

@interface UIActionSheet (NonFirstResponder)
@end

@implementation UIActionSheet (NonFirstResponder)
- (BOOL)canBecomeFirstResponder
{
    return NO;
}
@end

There is the only one side effect of it. Your texField/textView retains focus during action sheet presenting. But it is not a big trouble I think.

Also one can subclass UIActionSheet in the same way.

It is working fine.

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    if(textField==myTextField2){
        [myTextField1 resignFirstResponder];
        [self showActionSheet];
        return NO;
    }
    return YES;      
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!