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 8267841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:40:49+00:00 2026-06-08T05:40:49+00:00

I have an application with drag and drop a UIView feature. I should only

  • 0

I have an application with drag and drop a UIView feature. I should only let 3 drags and not more than that. How do I keep track of the number of drags? I tried incrementing a counter in touchesBegan(), but the counter got incremented on tapping the view also. I want it to be increased only when I drag the view. Also can you provide a snippet for dragging and dropping a small UIView into another view on the top. I don’t know if I have used the right method.

My code:

(void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
    [self.view setMultipleTouchEnabled:NO]; 
    UITouch *touch = [touches anyObject]; 
    if ([touch view] == option1View || [touch view] == option2View ||
        [touch view] == option3View ||[touch view] == option4View) { 
            CGRect frame = [[touch view] frame];
            if(counter == 1){
                frame.origin.x = 10;
                frame.origin.y = 90; 
            }
            [[touch view] setFrame:frame]; 

I incremented my counter in touched began. I checked that if condition for 3 cases of counter

  • 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-06-08T05:40:52+00:00Added an answer on June 8, 2026 at 5:40 am

    Apple has a gesture recognizer exactly for dragging. It is UIPangestureRecognizer. It recognizes just pan gestures and not tap or something else.

    Here is doc http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIPanGestureRecognizer_Class/Reference/Reference.html

    You can manage your pan/drag gestures easier then using touchesBegan() etc…

    From Doc:
    UIGestureRecognizerStateEnded ends when all fingers are lifted.

    You can check the state and increment your counter.

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

Sidebar

Related Questions

I have an application that has drag and drop functionality to import images and
I have a Silverlight application that needs Drag-And-Drop functionality because I allow the user
I have an HTML5 application that allows users to drag-n-drop an image to a
In my application, I have a TreeView that allows drag/drop. I have all the
I have a C# application in which I am implementing a drag drop functionality
I have a drag and drop handler in my Flex application. The drag proxy,
I have built so far an application that allows the user to drag and
I have implemented drag and drop in my application, but am having some difficulty
I have been asked to build an application where I can drag and drop
I have an application with a file and folder list control which supports Drag&Drop

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.