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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:20:51+00:00 2026-06-09T19:20:51+00:00

How can I get touch offset when using UITouch ? I am doing a

  • 0

How can I get touch offset when using UITouch? I am doing a project like a remote control. I have a view set to multi-touched and I want the view to act like a touch pad for Mac, so I need the touch offsets when people move to control the mouse. Any ideas?

  • 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-09T19:20:53+00:00Added an answer on June 9, 2026 at 7:20 pm

    This can be accomplished with a UIPanGestureRecognizer by measuring the diagonal distance from the center of the screen to the current touch location.

    #import <QuartzCore/QuartzCore.h>
    

    Declare the gesture and hook it to self.view so that the entire screen responds to touch events.

    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(myPanRecognizerMethod:)];
    [pan setDelegate:self];
    [pan setMaximumNumberOfTouches:2];
    [pan setMinimumNumberOfTouches:1];
    [self.view setUserInteractionEnabled:YES];
    [self.view addGestureRecognizer:pan];
    

    Then in this method, we use the gesture recognizers state: UIGestureRecognizerStateChanged to update and integer that measures the diagonal distance between touch location and screen center as the touch location changes.

    -(void)myPanRecognizerMethod:(id)sender
    {
        [[[(UITapGestureRecognizer*)sender view] layer] removeAllAnimations];
        if ([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateChanged) {
            CGPoint touchLocation = [sender locationOfTouch:0 inView:self.view];
            NSNumber *distanceToTouchLocation = @(sqrtf(fabsf(powf(self.view.center.x - touchLocation.x, 2) + powf(self.view.center.y - touchLocation.y, 2))));
            NSLog(@"Distance from center screen to touch location is == %@",distanceToTouchLocation);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using touch listener on text view. I can get the touch coordinates
I know I can get touch events in my iPhone app. But these touch
How can I get input data from the rear touch pad on the Vita
You can get a list of databases using PRAGMA database_list or a list of
I'm basically trying to get all touch event data from something like a system
I have got a sprite that moves based on touch location. I am using
When the touch happens, I can get the CGPoint from where the touch was
I have this setting below, but when I touch the table cell, I get
I started using the MoveMe sample to get touch input working. basically, I define
i haves game with cocos2d i have many sprites i'm using touch to sprite

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.