普通的做法resignFirstResponder在UIModalPresentationFormSheet的时候不起效 加上如下代码:
[passwordField resignFirstResponder];
@try {
Class UIKeyboardImpl = NSClassFromString(@"UIKeyboardImpl");
id activeInstance = [UIKeyboardImpl performSelector:@selector(activeInstance)]; [activeInstance performSelector:@selector(dismissKeyboard)];
}
@catch (NSException *exception) {
NSLog(@"%@", exception);
}
注意这个是jailbreak开发的代码,appstore慎用。