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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:48:26+00:00 2026-06-09T11:48:26+00:00

Im sorry if this is a simple question for you.But i stuck here. I

  • 0

Im sorry if this is a simple question for you.But i stuck here.

I have added a pan gesture to the view.

I stuck with a point where i want to get the time interval, when user pan forward and backward in a view.

Now i used this code for getting the time interval,

if ([sender state] == UIGestureRecognizerStateBegan )
        {
            startTime = [[NSDate alloc]init];}

else if([sender state] == UIGestureRecognizerStateChanged ) 
        {         
            CGPoint velocity = [sender velocityInView:self.imageView];

            if(velocity.x > 0)
            {

                NSLog(@"gesture went right");
            }
            else
            {

                NSLog(@"gesture went left");
            }

            double chagedTime = [startTime timeIntervalSinceNow] * -1000.0;
            NSLog(@"%f changed ",chagedTime);
}

Now I’m getting the time interval when user start to pan forward, but the problem is suppose when user start to pan backward the time interval is also increasing.

So how can i time interval increasing while panning forward and time interval decrease while panning backward.

Hoping for your help.

Thanks in advance.

  • 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-09T11:48:28+00:00Added an answer on June 9, 2026 at 11:48 am

    If I’m reading your question correctly, you want to record the amount of time a user spends panning forward, and subtract from that the amount of time a user spends panning backwards.

    //Declared:
    double netTimeInterval;
    double previousStartTime;
    
    if ([sender state] == UIGestureRecognizerStateBegan )
        netTimeInterval = 0;
    else if([sender state] == UIGestureRecognizerStateChanged )
    {
        CGPoint velocity = [sender velocityInView:sender.view];
        double changedTime;
        changedTime = (velocity.x > 0)? (CFAbsoluteTimeGetCurrent()-previousStartTime):(previousStartTime-CFAbsoluteTimeGetCurrent());
        //Conversion from seconds to microseconds
        changedTime *=1000;
    
        netTimeInterval += changedTime;
        NSLog(@"%f",changedTime);
        NSLog(@"%f",netTimeInterval);
    }
    previousStartTime = CFAbsoluteTimeGetCurrent();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for this simple question but I am stuck here. I am trying to
Sorry to bother you with such a simple question, but I'm stuck here since
Hey guys, sorry for this probably fairly simple question but I'm starting to get
Sorry for this question but I am stuck. I have folowing syntax: class xx
sorry this is such a simple question but I can't figure it out. How
Sorry for this simple question, but I can't solve it... There is an example:
Sorry if this is a dead simple question but I'm confused from the documentation
Im sorry for this probably dumm question, but I want to simply open modals
Sorry for this simple question, but i'm missing the forest through the trees. These
Hello I am sorry to bother you with such a simple question but this

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.