0

I am facing a problem in using UIButton action and touchesmoved. The scenario is, when I drag my fingers over a series of buttons its actions should be called.I button can be touched individually as well.

I used the touchesmoved method to find out the touch points on uibutton to trigger its action. The problem with that approach is, When I tap somewhere in view and move my finger over button everything works, but if I start my touch on UIButton itself touchesmoved method is not called.

Vignesh
  • 10,205
  • 2
  • 35
  • 73
  • Sounds like you implemented touchesMoved in the UIView that contains all the buttons. So the view has a implementation of touchesMoved. Now, when you start in the button, the button does not have an instance of touchesMoved, so it doesn't call any function and nothing happens. – ColdLogic Jul 15 '11 at 20:30

2 Answers2

3

Check below, will be helpful for you.

Handling touch events for UIButtons in iPhone

Is there a way to pass touches through on the iPhone?

touchesBegin & touchesMove Xcode Obj C Question

Community
  • 1
  • 1
Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76
0

If you don't need to know the exact location of the touch, just when they swiped over it, you can add a target to it and use one of the many UIControlEvents, like UIControlEventTouchDragInside, etc.

Here's the full enum straight from UIControl.h

enum {
    UIControlEventTouchDown           = 1 <<  0,      // on all touch downs
    UIControlEventTouchDownRepeat     = 1 <<  1,      // on multiple touchdowns (tap count > 1)
    UIControlEventTouchDragInside     = 1 <<  2,
    UIControlEventTouchDragOutside    = 1 <<  3,
    UIControlEventTouchDragEnter      = 1 <<  4,
    UIControlEventTouchDragExit       = 1 <<  5,
    UIControlEventTouchUpInside       = 1 <<  6,
    UIControlEventTouchUpOutside      = 1 <<  7,
    UIControlEventTouchCancel         = 1 <<  8,

    UIControlEventValueChanged        = 1 << 12,     // sliders, etc.

    UIControlEventEditingDidBegin     = 1 << 16,     // UITextField
    UIControlEventEditingChanged      = 1 << 17,
    UIControlEventEditingDidEnd       = 1 << 18,
    UIControlEventEditingDidEndOnExit = 1 << 19,     // 'return key' ending editing

    UIControlEventAllTouchEvents      = 0x00000FFF,  // for touch events
    UIControlEventAllEditingEvents    = 0x000F0000,  // for UITextField
    UIControlEventApplicationReserved = 0x0F000000,  // range available for application use
    UIControlEventSystemReserved      = 0xF0000000,  // range reserved for internal framework use
    UIControlEventAllEvents           = 0xFFFFFFFF
};
typedef NSUInteger UIControlEvents;
EmilioPelaez
  • 18,758
  • 6
  • 46
  • 50