UIResponder Troubles

无人久伴 提交于 2019-12-08 03:04:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!