问题
Tonight I've been battling with UIResponder. Here's my predicament.
If I put in
- (BOOL)canBecomeFirstResponder{
return YES;
}
to my mainViewController then I can get shake events..
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventSubtypeMotionShake) {
//do something
}
}
However, this means that when I call things like mail forms and webviews, the keyboard does not show up.
Is there any way I can get both shakes working and keyboard working in modal views?
I've tried adding [self resignFirstResponder]; in -viewDidDissapear, which gets called when a modal pops over, but no luck.
Cheers
回答1:
I had the same problem with iOS < 5.0, shake event and showing a mail form. You have to resign the first responder before the new modal view controller is being presented.
来源:https://stackoverflow.com/questions/6581395/uiresponder-troubles