// Мне нужно отправить событие через @selector ([move: event])
заранее спасибо.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
moveTimer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(move:) userInfo:nil repeats:YES];
}
// моя функция перемещения
- (void)move:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (location.x > myImageView.center.x){
[UIView animateWithDuration:0.001 animations:^{
myImageView.center = CGPointMake(myImageView.center.x+5, myImageView.center.y);
}];
}
else if (location.x < myImageView.center.x){
[UIView animateWithDuration:0.001 animations:^{
myImageView.center = CGPointMake(myImageView.center.x-5, myImageView.center.y);
}];
}
if (location.y < myImageView.center.y){
[UIView animateWithDuration:0.001 animations:^{
myImageView.center = CGPointMake(myImageView.center.x, myImageView.center.y-5);
}];
}
else if (location.y > myImageView.center.y){
[UIView animateWithDuration:0.001 animations:^{
myImageView.center = CGPointMake(myImageView.center.x, myImageView.center.y+5);
}];
}
}