【发布时间】:2011-03-09 23:32:23
【问题描述】:
我有一个 UIButton 将 draginside 事件发送到:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
它通过 viewDidLoad 中的以下代码来做到这一点:
[colourButton1 addTarget:self action:@selector(touchesBegan:withEvent:) forControlEvents:UIControlEventTouchDown];
在它发送到的方法中,有以下行:
UITouch *myTouch = [touches anyObject];
由于某种原因,当在 UIButton 内拖动时,这会使应用程序崩溃。任何想法为什么?
编辑:解决方案..
-(IBAction)buttonDragged:(id)button withEvent:(UIEvent*)event {
NSSet *touches = [event touchesForView:colourButton1];
[self touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event];
}
【问题讨论】:
标签: iphone objective-c uibutton uitouch