I have a UIView which covers all of a UITableView. The UIView is using gesture recognizers for control of what the table displays. I still need the vertical UITableView scrolling and row taps. How do I pass these on to the table from the gesture recognizers?
A pan gesture occurs any time a person moves one or more fingers around the screen. A screen-edge pan gesture is a specialized pan gesture that originates from the edge of the screen. Use the UIPanGestureRecognizer class for pan gestures and the UIScreenEdgePanGestureRecognizer class for screen-edge pan gestures.
Tap and swipe are two common gestures that allow the user to perform primary actions on their mobile devices. The tap gesture is essentially a brief touch of the mobile screen surface with the fingertip. Common uses of this gesture in iOS and Android devices include: Select or submit. Activate.
UITapGestureRecognizer is a concrete subclass of UIGestureRecognizer . For gesture recognition, the specified number of fingers must tap the view a specified number of times. Although taps are discrete gestures, they're discrete for each state of the gesture recognizer.
The tap gesture recognizer appears in the Document Outline on the left. We need to implement an action that defines what happens when the user taps the image view. Open ViewController. swift and define a method with name didTapImageView(_:) . It accepts the tap gesture recognizer as its only argument.
If you need to know your cell's indexPath:
- (void)handleSwipeFrom:(UIGestureRecognizer *)recognizer {
CGPoint swipeLocation = [recognizer locationInView:self.tableView];
NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation];
UITableViewCell *swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];
}
This was previously answered in UIGestureRecognizer and UITableViewCell issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With