1. In the view under Uimodalpresentationformsheet (IPad device, without a uinavigationcontroller), if you use the
[Inputview Resignfirstresponder];
Keyboard can not be put up, you need to use the following ways:
A:
@try
{
Class Uikeyboardimpl = nsclassfromstring (@ "Uikeyboardimpl");
ID activeinstance = [uikeyboardimpl performselector: @selector (activeinstance)];
[Activeinstance performselector: @selector (Dismisskeyboard)];
}
@catch (NSException *exception)
{
NSLog (@ "Exception:%@", Exception);
}
The method above is not approved because it uses Apple's private API.
B. The view under Uimodalpresentationformsheet cannot be resignfirstresponder because after entering this mode, the system returns the values in the following method to Yes:
-(BOOL) disablesautomatickeyboarddismissal
{
return YES;
}//Disablesautomatickeyboarddismissal, this method is in Uiviewcontroller.
After you change the return value to No, you can hide the keyboard normally using the Resignfirstresponsder method, but this method still fails in Uinavigationcontroller, which is supplemented by the following.
2. If you display the Uimodalpresentationformsheet view in Uinavigationcontroller, then rewrite it in Uinavigationcontroller Rootviewcontroller
The Disablesautomatickeyboarddismissal method will also not be able to enable the Resignfirstresponder method effect because the displayed view is Uinavigationcontroller, Should be in the Uinavigationcontroller.
To override the Disablesautomatickeyboarddismissal method. This is done by extending the way to the Uinavigationcontroller to override this method:
#import<UIKit/UIKit.h>@interfaceUinavigationcontroller (Uinavigationcontroller_keyboarddismiss)-(BOOL) disablesautomatickeyboarddismissal;@end#import "Uinavigationcontroller+uinavigationcontroller_keyboarddismiss.h"@implementationUinavigationcontroller (Uinavigationcontroller_keyboarddismiss)-(BOOL) disablesautomatickeyboarddismissal{returnNO;}//Disablesautomatickeyboarddismissal@end
After rewriting the Disablesautomatickeyboarddismissal method by Uinavigationcontroller category, the problem of Resignfirstresponder method invalidation can be solved.
Reference: http://stackoverflow.com/questions/3372333/ Ipad-keyboard-will-not-dismiss-if-modal-view-controller-presentation-style-is-ui