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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:35:30+00:00 2026-06-12T05:35:30+00:00

I am developing an app, Which has feature that dragging and rotating the image

  • 0

I am developing an app, Which has feature that dragging and rotating the image view.

I have implemented to drag and rotate successfully by using below code

In touchesBegan Method

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];

    touchStart = [[touches anyObject] locationInView:imageView];
    isResizingLR = (containerVw.bounds.size.width - touchStart.x < kResizeThumbSize && containerVw.bounds.size.height - touchStart.y < kResizeThumbSize);

}

In touchesMoved Method

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

     CGPoint touchPoint = [[touches anyObject] locationInView:containerVw];
     CGPoint previous=[[touches anyObject]previousLocationInView:containerVw];
     UITouch *touch = [[event allTouches] anyObject];

     if (isResizingLR) {

        CGFloat currA = [self pointToAngleFromCenter:[touch locationInView:containerVw.superview]] ;
        CGFloat prevA = [self pointToAngleFromCenter:[touch previousLocationInView:containerVw.superview]] ;
        // the current value of the rotation angle
        CGFloat tranA = atan2(containerVw.transform.b, containerVw.transform.a) ;
        // the angle difference between last touch and the current touch
        CGFloat diffA = currA - prevA ;
        // the new angle resulting from applying the difference
        CGFloat angle1 = tranA - diffA ;

        CGAffineTransform t = CGAffineTransformMakeRotation(angle1) ;
        containerVw.transform =t;
       }

      if (!isResizingLR) {
         containerVw.center = CGPointMake(containerVw.center.x + touchPoint.x - touchStart.x,           containerVw.center.y + touchPoint.y - touchStart.y);

       }
}

My Problem

Above code is working fine until rotating the image view after dragging. In case if i drag the image view after rotating it. image view has gone away from screen.

In touchesEnd method i tried to print the image view frame. for example my image view frame at the beginning is (100,100,150,149) after rotating it the image view 160º frame has changed to (103,31,182,183) up to now its working fine.

After rotating it if try to move an image view, the image view has gone away from screen now the frame has changed to (615,-212,182,183)

Please guide me how do i resolve it.

  • 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-12T05:35:32+00:00Added an answer on June 12, 2026 at 5:35 am

    Have a look at this project. This may help you. But here, the movement is handled by gestures and not by touch. It may solve your problem.

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

Sidebar

Related Questions

So I am developing an app which contains a table view that has images
I'm developing an app that has a few services, which communicate using AIDL. In
I am developing an app which has 9 image views in a 3x3 matrix.
I am developing an app which has a list view with custom layout as
Am developing an app which has a calculator function: for example, i have 4
I'm developing an app and I have one ListActivity , which has choice mode
I'm developing an iOS 5 app using Storyboard. I have UITabBarController which has 3
I am developing an android app which has Facebook integration in it. I have
for a client, I have been developing an app which has been tailored to
I am developing a playlist app for Android which has a ListView that contains

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.