Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:14:12+00:00 2026-05-27T17:14:12+00:00

I have four UIGestureSwipeRecognizers registered (one for each direction), and they work as intended

  • 0

I have four UIGestureSwipeRecognizers registered (one for each direction), and they work as intended on an iPhone 4/4S (iOS 4.3 and 5) and iPad 1/2 (iOS 4.NotSure and 5). It is a game, so the only allowed device orientations are LandscapeRight and LandscapeLeft. However, on an iPhone 3G with iOS 4.1, the swipe recognizers respond as if the device were being held in Portrait. In other words, on the iPhone 3G, what should be an Up swipe in LandscapeLeft gets registered as a Right swipe. In fact, all four swipe recognizers behave as if the device were in Portrait; however, I have checked [[UIDevice currentDevice] orientation] and it always returns UIDeviceOrientationLandscapeLeft

Also, the app is a game built upon the cocos2d 1.0.1 template.

What could I be doing wrong?

Here’s my code where I register the four swipe recognizers:

_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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:14:13+00:00Added an answer on May 27, 2026 at 5:14 pm

    There’s no way around it other than converting the directions. I’ve done this in Kobold2D‘s swipe gesture recognizer using this internal method, it should be easy to adapt:

    -(KKSwipeGestureDirection) convertSwipeDirection:(UISwipeGestureRecognizerDirection)uiDirection
    {
        // portrait mode direction remains unchanged
        KKSwipeGestureDirection direction = (KKSwipeGestureDirection)uiDirection;
    
        switch (uiDirection)
        {
            case UISwipeGestureRecognizerDirectionRight:
            {
                switch (director.deviceOrientation)
                {
                    case CCDeviceOrientationPortraitUpsideDown:
                        direction = KKSwipeGestureDirectionLeft;
                        break;
                    case CCDeviceOrientationLandscapeLeft:
                        direction = KKSwipeGestureDirectionUp;
                        break;
                    case CCDeviceOrientationLandscapeRight:
                        direction = KKSwipeGestureDirectionDown;
                        break;
                    default:
                        break;
                }
                break;
            }
    
            case UISwipeGestureRecognizerDirectionLeft:
            {
                switch (director.deviceOrientation)
                {
                    case CCDeviceOrientationPortraitUpsideDown:
                        direction = KKSwipeGestureDirectionRight;
                        break;
                    case CCDeviceOrientationLandscapeLeft:
                        direction = KKSwipeGestureDirectionDown;
                        break;
                    case CCDeviceOrientationLandscapeRight:
                        direction = KKSwipeGestureDirectionUp;
                        break;
                    default:
                        break;
                }
                break;
            }
    
            case UISwipeGestureRecognizerDirectionUp:
            {
                switch (director.deviceOrientation)
                {
                    case CCDeviceOrientationPortraitUpsideDown:
                        direction = KKSwipeGestureDirectionDown;
                        break;
                    case CCDeviceOrientationLandscapeLeft:
                        direction = KKSwipeGestureDirectionLeft;
                        break;
                    case CCDeviceOrientationLandscapeRight:
                        direction = KKSwipeGestureDirectionRight;
                        break;
                    default:
                        break;
                }
                break;
            }
    
            case UISwipeGestureRecognizerDirectionDown:
            {
                switch (director.deviceOrientation)
                {
                    case CCDeviceOrientationPortraitUpsideDown:
                        direction = KKSwipeGestureDirectionUp;
                        break;
                    case CCDeviceOrientationLandscapeLeft:
                        direction = KKSwipeGestureDirectionRight;
                        break;
                    case CCDeviceOrientationLandscapeRight:
                        direction = KKSwipeGestureDirectionLeft;
                        break;
                    default:
                        break;
                }
                break;
            }
        }
    
        return direction;
    }
    

    For those who are using Cocos2D 2.x you should know that CCDirector no longer has the deviceOrientation property. Instead you just get the orientation from UIDevice:

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    

    Then just change all case labels by replacing the CC with the UI prefix, for example

    case CCDeviceOrientationPortraitUpsideDown:
    

    should be changed to:

    case UIDeviceOrientationPortraitUpsideDown:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four divs that are each one column tables with many rows. They
I have four UINavigationControllers assigned each to a tab in a UITabBarController. Each UINavigationController
I have four models that are related to one another, the way I have
I have four TSpeedButton objects, each with a BMP file assigned as a glyph
I have four product gallery with the possibility to check the detail of each
I have four divs in a row and whichever one you click on, the
I have four tables each with its own form, all these table share same
I have four arrays(array1..4) each containing four strings e.g var array1 = ['array1item1', 'array1item2',
I have four buttons arranged in a 2x2 TableLayout. These buttons each have an
I have four arrays of data (3072 bytes each.) I want to point to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.