问题描述
今晚我一直在与UIResponder作战。这是我的困境。
Tonight I've been battling with UIResponder. Here's my predicament.
如果我输入
- (BOOL)canBecomeFirstResponder{
return YES;
}
到我的mainViewController然后我可以获得震动事件..
to my mainViewController then I can get shake events..
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventSubtypeMotionShake) {
//do something
}
}
但是,这意味着当我调用邮件表单和Web视图等内容时,键盘不会显示出来。
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?
我是尝试添加[self resignFirstResponder];
in -viewDidDissapear,当一个模态弹出时被调用,但没有运气。
I've tried adding [self resignFirstResponder];in -viewDidDissapear, which gets called when a modal pops over, but no luck.
干杯
推荐答案
我遇到了与iOS相同的问题< 5.0,摇动事件并显示邮件表格。在呈现新的模态视图控制器之前,您必须重新签署第一个响应者。
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.
这篇关于UIResponder麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!