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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:15:19+00:00 2026-06-06T19:15:19+00:00

I am facing problem with UIPanGestureRecognizer. suppose i am adding 10 button dynamicaly using

  • 0

I am facing problem with UIPanGestureRecognizer. suppose i am adding 10 button dynamicaly using diffrent tags when i add first button the try to drag it to other place then its works fine. and then if i add other button then try to drag that second button then even its works fine but if then i would lyk to drag first button then it not being draged and. and message shown in log is Ignoring call to [UIPanGestureRecognizer setTranslation:inView:] since gesture recognizer is not active.
gesture is working only on recently added button. below is the code that i am using


Here is code to add buttons

    NSUInteger counter = 1;
    if([ButtonArray count] !=0 ){
        NSLog(@"%d",[ButtonArray count]);
        NSLog(@"hi");
        counter = [ButtonArray count] + 1;

    }
    [ButtonArray addObject:[NSString stringWithFormat:@"%d",counter]];
    NSLog(@"%d",1);
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn setTag:counter];
    btn.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
    //[btn addTarget:self action:@selector(Dragged:withEvent:) forControlEvents:UIControlEventTouchDragInside];
    //[self.view addSubview:btn];
    btn.userInteractionEnabled = YES;

    gesture = [[UIPanGestureRecognizer alloc] 
                                        initWithTarget:self 
                                        action:@selector(labelDragged:)];
    [btn addGestureRecognizer:gesture];
    // add it

[self.view addSubview:btn];

here is code for gesture

    UIButton *button = (UIButton *)gesture.view;

CGPoint translation = [gesture translationInView:button];


// move button
button.center = CGPointMake(button.center.x + translation.x, 
                           button.center.y + translation.y);

// reset translation
[gesture setTranslation:CGPointZero inView:button];

  • 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-06T19:15:20+00:00Added an answer on June 6, 2026 at 7:15 pm

    I suspect the problem comes down to this:

    gesture = [[UIPanGestureRecognizer alloc] 
                                        initWithTarget:self 
                                        action:@selector(labelDragged:)];
    

    I tend to think from your code that gesture is some property in your class. In this case you are constantly overriding the old gesture when you create a new one. That would also explain the behavior you describe.

    EDIT:

    you do not strictly need to store your gesture recognizers in a property; it would be enough to do:

    UIPanGestureRecognizer* localgesture = [[UIPanGestureRecognizer alloc] 
                                        initWithTarget:self 
                                        action:@selector(labelDragged:)];
    [btn addGestureRecognizer:localgesture];
    

    then, when the labelDragged method is called, you can use its recognizer argument to know which gesture recognizers fired:

    - (void)labelDragged:(UIGestureRecognizer *)gestureRecognizer;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing problem in getting Facebook data I am using Facebook SDK for
I am facing problem while aligning two text, one in center and other text
I am facing problem in showing the preview of first letter in Android listview,
Note : In WinForm I facing problem in TableLayoutPanel. I adding and removing the
I am facing problem adding and deleting DataRows from a DataTable that is meant
I am facing problem in android-ndk. When i try to call a java nan-static
I am using FMDB wrapper to store data in sqlite. I am facing problem
Facing problem with every fetch i want to make using EF Query model.Place here
I am facing problem for reading xml file using javascript. It works fine in
I am facing problem. I need to build one app in two ways, first

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.