成为FirstResponder似乎仅在第一次摇动手势时起作用 [英] becomeFirstResponder seems to work only 1st time for shake gesture

查看:60
本文介绍了成为FirstResponder似乎仅在第一次摇动手势时起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过在UIViewController中执行此操作来使我的应用程序与手势兼容:

I'm making my app shake-gesture-compatible by doing this in my UIViewController:

- (void)viewWillAppear:(BOOL)animated
{
    [self.view becomeFirstResponder];
    [super viewWillAppear:animated];
}

问题是当我翻转到另一个视图时(我正在使用"Utility App"模板,该模板具有一个翻转视图和一个用于管理这两个视图的根视图控制器),当我回来时,摇动手势将停止工作.

The problem is that when I flip to another view (I'm using the "Utility App" template which has a flipside view and a root view controller to manage them both) the shake gesture ceases to work when I come back.

我看到调用了viewWillAppear方法,只是似乎该视图没有第二次重新获得第一响应者状态.

I see that the viewWillAppear method is called, it just doesn't seem that the view regains first responder status the second time around.

推荐答案

谁知道..您必须将呼叫放在viewDidAppear中的becomeFirstResponder中而不是viewWillAppear中.

Who knew .. you have to put the call to becomeFirstResponder in viewDidAppear instead of viewWillAppear.

这篇关于成为FirstResponder似乎仅在第一次摇动手势时起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆