UIResponder 问题
今晚我一直在与 UIResponder 作斗争。这是我的困境。
如果我放入
- (BOOL)canBecomeFirstResponder{
return YES;
}
mainViewController 中,那么我可以获得摇动事件。
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventSubtypeMotionShake) {
//do something
}
}
但是,这意味着当我调用邮件表单和 webview 之类的东西时,键盘不会显示。
有什么方法可以让震动和键盘在模态视图中同时工作吗?
我尝试添加 [self resignFirstResponder]; 在 -viewDidDissapear 中,当模态弹出时会调用它,但运气不佳。
干杯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 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.