[IOS SDK] - affects a specific object?

When I touch anywhere on the screen, the Bedgan event is affected. but I could not handle it, as if I touch a specific object, like a UIImageView?

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

 UITouch *touch = [[event allTouches] anyObject];

 CGPoint location = [touch locationInView: touch.view];

 imageView.center = location;

}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

 [self touchesBegan:touches withEvent:event];

}
+3
source share
1 answer

Ok, found a solution, here is the code:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [[event allTouches] anyObject];

    if ([touch view] == imageView) {

        CGPoint location = [touch locationInView: self.view];

        imageView.center = location;

    }

}
+13
source

Source: https://habr.com/ru/post/1780916/


All Articles