普通的做法resignFirstResponder在UIModalPresentationFormSheet的时候不起效 加上如下代码:
@try {
Class UIKeyboardImpl = NSClassFromString(@"UIKeyboardImpl");
id activeInstance = [UIKeyboardImpl performSelector:@selector(activeInstance)]; [activeInstance performSelector:@selector(dismissKeyboard)];
}
@catch (NSException *exception) {
NSLog(@"%@", exception);
}
注意这个是jailbreak开发的代码,appstore慎用。
本文介绍了一种特殊的方法来解决iOS中UIModalPresentationFormSheet模式下无法通过普通方式关闭键盘的问题。这种方法涉及使用UIKeyboardImpl类的私有API,因此仅适用于越狱设备,不适合App Store应用。

被折叠的 条评论
为什么被折叠?



