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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:13:57+00:00 2026-06-11T09:13:57+00:00

Possible Duplicate: Making use of velocityInView with UIPanGestureRecognizer I am creating an app in

  • 0

Possible Duplicate:
Making use of velocityInView with UIPanGestureRecognizer

I am creating an app in which I am drawing a path based on touchMoved. I want to make the width of line based on the velocity of touch. I can achieve this effect, but there is no smoothness in this.

CODE:

-(float) clampf:(float) v: (float) min: (float) max 
{
    if( v < min ) v = min;
    if( v > max ) v = max;

    return v;
}

- (float)extractSize:(UIPanGestureRecognizer *)panGestureRecognizer
{
    vel = [gesture velocityInView:self.view];
    mag = sqrtf((vel.x * vel.x) + (vel.y * vel.y)); // pythagoras theorem (a(square) + b(square) = c(square))
    final = mag/166.0f;
    final = [self clampf:final :1 :40];
    NSLog(@"%f", final);

    if ([velocities count] > 1) {
        final =  final * 0.2f + [[velocities objectAtIndex:[velocities count] - 1] floatValue] * 0.8f;
    }
    [velocities addObject:[NSNumber numberWithFloat:final]];
    return final;
}

But i am getting something like this:

enter image description here

  • 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-11T09:13:57+00:00Added an answer on June 11, 2026 at 9:13 am

    I have made the similar effect before. I was using the original touch event methods (touchesBegan, etc.) and calculated the velocity by myself. Every thing looks all right.

    I am not sure if the velocityInView method always gives your the correct result during user moving their finger, maybe you should try to calculate the velocity by yourself and see if the problem is gone.

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

Sidebar

Related Questions

Possible Duplicate: Why use getters and setters? Is there any advantage to making methods
Possible Duplicate: CSS Opacity Property I'm making a layer on an image which has
Possible Duplicate: How do you make strings XMLsafe? I am making xml and part
Possible Duplicate: Making a log4j console appender use different colors for different threads I
Possible Duplicate: How can you use optional parameters in C#? I am making text
Possible Duplicate: Making my ajax updated div fade in I want the content from
Possible Duplicate: iPhone : making UIBarButtonItem that is arrow shaped Creating a left-arrow button
Possible Duplicate: How to use “\” in a string without making it an escape
Possible Duplicate: Making the iPhone vibrate How can you programmatically make the iPhone vibrate?
Possible Duplicate: Making Live Clock javascript I want to create a clock, with javascript

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.