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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:35:40+00:00 2026-05-23T15:35:40+00:00

I have a view control and inside I plan to place some controls like

  • 0

I have a view control and inside I plan to place some controls like buttons textbox etc… I can drag my view along the x axis like:

1)

enter image description here

2)

enter image description here

with the following code:

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

    if( [touch view] == ViewMain)
    {
        CGPoint location = [touch locationInView:self.view];
        displaceX = location.x - ViewMain.center.x;        
        displaceY = ViewMain.center.y;        
        startPosX = location.x - displaceX;
    }

    CurrentTime = [[NSDate date] timeIntervalSince1970];

}


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



    UITouch *touch = [[event allTouches] anyObject];

    if( [touch view] == ViewMain)
    {
        CGPoint location = [touch locationInView:self.view];
        location.x =location.x - displaceX;
        location.y = displaceY;
        ViewMain.center = location;
    }  


}

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

    double time = [[NSDate date] timeIntervalSince1970]-CurrentTime;


    UITouch *touch = [[event allTouches] anyObject];

    if( [touch view] == ViewMain)
    {
        CGPoint location = [touch locationInView:self.view];
        location.x =location.x - displaceX;
        location.y = displaceY;
        ViewMain.center = location;
        double speed = (ViewMain.center.x-startPosX)/(time*2);
        NSLog(@"speed: %f", speed);

    }
}

not that I have to add the global variables:

float displaceX = 0;
float displaceY = 0;
float startPosX = 0;
float startPosY = 0;
double CurrentTime;

the reason why I created those variables is so that when I start dragging the view the view moves from the point where I touch it instead of from the middle.

Anyways if I touch a button or image the view will not drag even though the images have transparency on the background. I want to be able to still be able to drag the view regardless if there is an image on top of the view. I where thinking that maybe I need to place a large transparent view on top of everything but I need to have buttons, images etc. I want to be able to drag a view just like you can with:

enter image description here

note that I was able to drag the view regardless of wither I first touched an app/image or text. How could I do that?

  • 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-05-23T15:35:40+00:00Added an answer on May 23, 2026 at 3:35 pm

    I think your problem is that if you touch a UIButton or a UIImageView with interaction enabled, it doesn’t pass the touch along.
    For the images, uncheck the User Interaction Enabledproperty in IB.
    For the buttons that are causing touchesBegan:withEvent:, etc. to not get called, then look at the following link: Is there a way to pass touches through on the iPhone?.

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

Sidebar

Related Questions

I have a Data Grid View inside a control that is displayed in a
I have a view user control that can post form. This control can be
Is it possible to have something like Data Grid or Grid View control in
I have a window with a tree view control inside and a XML file.
Well basically, I have this bing map control inside my Panorama view, when I
I have an image in image-view control. User can perform pan and zooming on
I have one view controller set with one graph view and segmented control inside
I have a textbox that is wired up to a calendar control like so
If have a filter form with multiple filter control inside like first name, last
I have a list view control which at the moment only allows one item

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.