I'd like to implement gestures on a ViewController.
UISwipeGestureRecognizer*gesture=[[UISwipeGestureRecognizer alloc] initWithTarget:selfaction:@selector(getSwipe:)];
gesture.direction =UISwipeGestureRecognizerDirectionDown;
self.view addGestureRecognizer:gesture;
Is it possible to have these methods in this ViewController's own class called GestureManager?
ios objective-c
It seems that the only way to do it is to say, "It depends on how you do it."
The point is this code.
[self.view addGestureRecognizer:gesture];
UIGestureRecognizer
(subclass in ) works for the first time by add
to UIView
(subclass in ).If you don't forget this, your implementation won't fail.
Can't I do this?
UISwipeGestureRecognizer*gesture=[[UISwipeGestureRecognizer alloc] initWithTarget: yourManager action:@selector(getSwipe:)];
gesture.direction =UISwipeGestureRecognizerDirectionDown;
self.view addGestureRecognizer:gesture;
© 2024 OneMinuteCode. All rights reserved.