【发布时间】:2011-11-03 19:05:47
【问题描述】:
我有一个自定义按钮类.. 我希望能够通过点击计数来控制这个按钮.. 当用户只点击一次时,按钮会弹出一个评论框。 当用户点击两次或点击一次并按住按钮超过 2 秒时,按钮将开始拖动。 我将这些行添加到我的自定义按钮类中以捕获拖动事件..
[self addTarget:self action:@selector(dragBegan:withEvent:) forControlEvents: UIControlEventTouchDown];
[self addTarget:self action:@selector(dragMoving:withEvent:) forControlEvents: UIControlEventTouchDragInside];
[self addTarget:self action:@selector(dragEnded:withEvent:) forControlEvents: UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
-(void)dragBegan:(UIControl *)c withEvent:ev {
[delegate customDragBegan:c withEvent:ev];
我试过这个功能:
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
};
但是当触摸结束时,dragEnds 不会触发..我有点搞砸了..
现在,我可以正确拖动按钮了.. 只需要弄清楚如何控制第一次尝试... 2 点击拖动,1 点击另一个功能..
提前谢谢你..
【问题讨论】:
标签: iphone cocoa-touch touch drag