0
我有一個UIButton發送所述draginside事件:的UIButton崩潰上uitouch事件
-(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];
}
因爲我希望用戶能夠在別處拖動按鈕。我在上面編輯了更多的代碼。 – Andrew 2011-03-10 00:17:23
我明白了。我不知道這是否是實現這種行爲的最佳方式,但是如果您絕對需要這樣做,您可以從事件觸及 - 'NSSet * touches = [event touchesForView:sender]' – hoha 2011-03-10 00:23:44
我會在哪裏放置該代碼? – Andrew 2011-03-10 00:40:16