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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:34:28+00:00 2026-06-03T23:34:28+00:00

I have, for example, a UIButton that I placed in IB. This UIButton has

  • 0

I have, for example, a UIButton that I placed in IB.

This UIButton has two functions depending on whether it is just touched up inside or dragged outside – it would be nice to at least keep it functioning for touch up inside.

I want to click on my button and ‘drag outside’ but use -touchesEnded over a rectangle when I finally release my click.

I know that one option is to ditch the UIButton and use -touchesBegan over a mask, but that is a lot more effort and requires a nice big rewrite (considering the 96 buttons).

So to rephrase slightly – I’ve clicked on a button and held down the mouse, while dragging the cursor (/finger) over to a different point in my view and I want my view to recognise a -touchesEnded when I finally let go. The problem is that the initial click is tied up in the button so -touchesEnded in my main view doesn’t happen…

Am i trying to do this the wrong way? Also, am I being clear?

EDIT: @Heckman has phrased the question well below

  • 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-03T23:34:31+00:00Added an answer on June 3, 2026 at 11:34 pm

    If I understand your question correctly, you are touching one button, that is contained within some UIView, and want to be able to drag your finger out, and recognize the point in the buttons superview.

    Sounds to me like you should detect the button press from the button, then make a call to the [UIButton superview], to tell the superview about the button pressing that started, and then handle the touch end within the view.

    To notify the superview of the button that was pressed call something like (from your UIButton):

    -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        [self.superview buttonPressed:self]
    }
    -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        [self.superview touchesEnded:touches withEvent:event];
    }
    

    In your superview code (if you have a property buttonPressed):

    -(void) buttonPressed:(UIButton *) button {
        _buttonPressed = button;
    }
    -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        if(self.buttonPressed) {
             //Process the release from your drag here. 
             for(UITouch * touch in touches) {
             //Use either of these to get the release position that you care about.
                 CGPoint releaseLocationInCurrentView = [touch locationInView:self];
                 CGPoint releaseLocationInButtonView = [touch locationInView:[self.buttonPressed]];
             }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is something that is stumping me; I have a simple UIButton with the
Anyone have example Rx code that shows how to execute an action due to
I have an example of some code that I see often in websites that
I have an example class containing two data points: public enum Sort { First,
I'm not quite sure how UIButton works. For example, if I have a timer
i have a UIView UIImageview UIButton and UISlider added as subview to UIView example:
I'm developing an application that has a view with UILabel , UIButton , UIImageView
I have a UITableViewController which has a UIView* called errorView that is used to
I have the following example class: Test.h: @interface Test : UIButton { NSString *value;
I have used this example in my application, http://spitzkoff.com/craig/?p=81 but its not calling/triggering the

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.