我注册了四个 UIGestureSwipeRecognizers(每个方向一个),它们在 iPhone 4/4S(iOS 4.3 和 5)和 iPad 1/2(iOS 4.NotSure 和 5)上按预期工作。这是一个游戏,所以唯一允许的设备方向是 LandscapeRight 和 LandscapeLeft。但是,在装有 iOS 4.1 的 iPhone 3G 上,滑动识别器的响应就像设备被握在纵向一样。换句话说,在 iPhone 3G 上,LandscapeLeft 中的向上滑动被注册为向右滑动。事实上,所有四个滑动识别器的行为都好像设备处于纵向状态。但是,我已经检查过了[[UIDevice currentDevice] orientation]
,它总是返回UIDeviceOrientationLandscapeLeft
此外,该应用程序是基于 cocos2d 1.0.1 模板构建的游戏。
我可能做错了什么?
这是我注册四个滑动识别器的代码:
_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;