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

  • Home
  • SEARCH
  • 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 8279243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:16:06+00:00 2026-06-08T09:16:06+00:00

I have one UIImageView having an image of an arrow. When user taps on

  • 0

I have one UIImageView having an image of an arrow. When user taps on the UIView this arrow should point to the direction of the tap maintaing its position it should just change the transform. I have implemented following code. But it not working as expected. I have added a screenshot. In this screenshot when i touch the point upper left the arrow direction should be as shown.But it is not happening so.

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

 UITouch *touch=[[event allTouches]anyObject];
 touchedPoint= [touch locationInView:touch.view];
 imageViews.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(rangle11));
 previousTouchedPoint = touchedPoint ;
}

- (CGFloat) pointPairToBearingDegrees:(CGPoint)startingPoint secondPoint:(CGPoint) endingPoint
{

 CGPoint originPoint = CGPointMake(endingPoint.x - startingPoint.x, endingPoint.y - startingPoint.y); // get origin point to origin by subtracting end from start
   float bearingRadians = atan2f(originPoint.y, originPoint.x); // get bearing in radians
float bearingDegrees = bearingRadians * (180.0 / M_PI); // convert to degrees
bearingDegrees = (bearingDegrees > 0.0 ? bearingDegrees : (360.0 + bearingDegrees)); // correct discontinuity
return bearingDegrees;
}

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-08T09:16:07+00:00Added an answer on June 8, 2026 at 9:16 am

    I assume you wanted an arrow image to point to where ever you touch, I tried and this is what i could come up with. I put an image view with an arrow pointing upwards (haven’t tried starting from any other position, log gives correct angles) and on touching on different locations it rotates and points to touched location. Hope it helps ( tried some old math 🙂 )

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    
        UITouch *touch=[[event allTouches]anyObject];
        touchedPoint= [touch locationInView:touch.view];
        CGFloat angle = [self getAngle:touchedPoint];
        imageView.transform = CGAffineTransformMakeRotation(angle);
    
    }
    
    -(CGFloat) getAngle: (CGPoint) touchedPoints
    {
        CGFloat x1 = imageView.center.x;
        CGFloat y1 = imageView.center.y;
    
        CGFloat x2 = touchedPoints.x;
        CGFloat y2 = touchedPoints.y;
    
        CGFloat x3 = x1;
        CGFloat y3 = y2;
    
        CGFloat oppSide = sqrtf(((x2-x3)*(x2-x3)) + ((y2-y3)*(y2-y3)));
        CGFloat adjSide = sqrtf(((x1-x3)*(x1-x3)) + ((y1-y3)*(y1-y3)));
    
        CGFloat angle = atanf(oppSide/adjSide);
        // Quadrant Identifiaction
        if(x2 < imageView.center.x)
        {
            angle = 0-angle;
        }
    
    
        if(y2 > imageView.center.y)
        {
            angle = M_PI/2 + (M_PI/2 -angle);
        }
         NSLog(@"Angle is %2f",angle*180/M_PI);
        return angle;
    
    }
    

    -anoop4real

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

Sidebar

Related Questions

I have one UIView with an UIImageview in which i have an image downloaded
I have a UIView container that has two UIImageView s inside it, one partially
Gentleones, I've got a UIImageView that I have in a UIView. This particular UIImageView
I have one UIImageView with a UIButton partially overlapping it. I want the user
i have two views and one viewcontroller: one contains UIImageView with image, second have
Been having real trouble with this one and wondered if someone may have found
I have 5 UIImageView and one UITapGestureRecognizer, but when I tap on my UIImageView
I have an UIView that contains two UIImageView (one is a cartoon, the other
I have one uiimageview which is added as subview in uiview. frame for uiimageview
I have created one UIImageView Here's code capView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:kARROW_CAP_NAME]]; capView.frame

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.