ios - How to make UIButton dragable but don't trigger click event -


i use method implement uibutton movable;

[button addtarget:self action:@selector(dragmoving:withevent:) forcontrolevents:uicontroleventtouchdraginside]; 

but trigger touchupinside event @ same time, , need touchupinside event other things.

so know how avoid this?

thanks lot;

use these code below solve it;

  [button addtarget:self action:@selector(touchdown:withevent:) forcontrolevents:uicontroleventtouchdown];      [button addtarget:self action:@selector(touchdraginside:withevent:) forcontrolevents:uicontroleventtouchdraginside];         [button addtarget:self action:@selector(touchupinside:withevent:) forcontrolevents:uicontroleventtouchupinside];      - (void) touchupinside :(uicontrol*)c withevent:ev{     nslog(@"touch inside");     if (count) {         nslog(@"here can clicking event");     } }      - (void) touchdown:(uicontrol*)c withevent:ev{     nslog(@"touch down");     count = yes; }      -(void) touchdraginside:(uicontrol*)c withevent:ev{     nslog(@"touch drag inside");     c.center = [[[ev alltouches] anyobject] locationinview:self.view];     count = no; } 

actually best way accomplish use uipangesturerecognizer , add button. handles dragging , can tap on without needing else.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -