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

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

asp.net - Configuring WCF Services in Code WCF 4.5 -