私は 4 つの UIGestureSwipeRecognizers を登録しており (各方向に 1 つ)、iPhone 4/4S (iOS 4.3 および 5) および iPad 1/2 (iOS 4.NotSure および 5) で意図したとおりに動作します。これはゲームであるため、許可されるデバイスの向きは LandscapeRight と LandscapeLeft のみです。ただし、iOS 4.1 を搭載した iPhone 3G では、デバイスが縦向きに保持されているかのように、スワイプ認識機能が応答します。つまり、iPhone 3G では、LandscapeLeft で上スワイプであるべきものが、右スワイプとして登録されます。実際、4 つのスワイプ認識機能はすべて、デバイスが縦向きであるかのように動作します。ただし、確認[[UIDevice currentDevice] orientation]
したところ、常に返されますUIDeviceOrientationLandscapeLeft
また、このアプリは cocos2d 1.0.1 テンプレートに基づいて構築されたゲームです。
私は何が間違っているのでしょうか?
4 つのスワイプ認識エンジンを登録するコードは次のとおりです。
_swipeRecognizer_right = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightDetected)];
_swipeRecognizer_right.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:_swipeRecognizer_right];
_swipeRecognizer_right.delegate = self;
_swipeRecognizer_left = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftDetected)];
_swipeRecognizer_left.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:_swipeRecognizer_left];
_swipeRecognizer_left.delegate = self;
_swipeRecognizer_up = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUpDetected)];
_swipeRecognizer_up.direction = UISwipeGestureRecognizerDirectionUp;
[self.view addGestureRecognizer:_swipeRecognizer_up];
_swipeRecognizer_up.delegate = self;
_swipeRecognizer_down = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDownDetected)];
_swipeRecognizer_down.direction = UISwipeGestureRecognizerDirectionDown;
[self.view addGestureRecognizer:_swipeRecognizer_down];
_swipeRecognizer_down.delegate = self;