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

  • SEARCH
  • Home
  • 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 6680093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:26:05+00:00 2026-05-26T04:26:05+00:00

I’m working on a simple note-taking/painting app. I have a view controller that works

  • 0

I’m working on a simple note-taking/painting app. I have a view controller that works like a paper/canvas. In it I want to implement UISwipeGestureRecognizer, for example, when the user quickly wants to show the menu he or she can swipe upwards instead of hitting my “edit” button, or maybe swipe left or right when he/she wants to change paper/note.

The problem is, when the user swipes (with two fingers) the app also draws a short line in the same direction.

I have implemented the UISwipeGestureRecognizer like this:

UISwipeGestureRecognizer *recognizer;

recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self   
action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
recognizer.numberOfTouchesRequired = 2;
[[self view] addGestureRecognizer:recognizer];
[recognizer release];

// Delegate method
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {

    return YES;
}

// Helper method for handeling swipes
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
    if (recognizer.direction == UISwipeGestureRecognizerDirectionUp) {
        [self enableEditingMode];
    }
}

The painting mechanism is handled in the same controller’s following methods:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

It seems like the three methods above gets called before my UIGestureRecognizer. I have tried to make a BOOL variable, and disable the painting code if the boolean variable is YES. But this didn’t work. Any other ideas on how to solve this problem would be great!

Note: I’m doing the swipe testing in the simulator. Maybe that effects it?

  • 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-26T04:26:06+00:00Added an answer on May 26, 2026 at 4:26 am

    I might have got it to work. Have only tested it in the simulator yet though, unsure if it will work on a device since the simulator recognizes two finger touches instantly. The solution looks like this (as of http://www.iphonedevsdk.com/forum/iphone-sdk-development/23537-implemented-touchesbegan-only-giving-me-one-touch.html):

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    
        NSSet *allTouches = [touches setByAddingObjectsFromSet:[event allTouches]];
        if (allTouches.count== 1) {
            if (isUsingPen) {
                [self painting:touches];
            }
            if (isUsingEraser) {
                [self erasing:touches];
            }  
        }
    }
    

    I will notify if this works on a device as well, or have anyone else tried this approach on a device?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.