Closed optme closed 10 years ago
Maybe you can play with cancelsTouchesInView=NO or just avoid adding the gesture recognizer to the full view.
I have tested and made a pull request which fixes this issue: https://github.com/John-Lluch/SWRevealViewController/pull/143
I tried the latest version of SWRevealViewController and still encounter the same problem, can not swipe to delete the tableview cell in the front view.
my code in the front view controller as below:
_settingButton.target = self.revealViewController;
_settingButton.action = @selector(revealToggle:);
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
I also tried work around in another post
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
but it does not work for my case.
May I know any work around for it?
Still an ongoing issue can confirm.
Shouldn't this issue be reopened?
You can either add the reveal recognizer to a view not interfering with your cells or you can now implement the following delegate method to return yes.
- (BOOL)revealController:(SWRevealViewController *)revealController
panGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
Please let me know if any of these doesn't work.
Hi, i've the same problem. I've updated SWRevealViewController with 2.1.0 but nothing's changed. So i've modify this function as below:
(BOOL)gestureRecognizer:(UIGestureRecognizer )gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer )otherGestureRecognizer { if ( gestureRecognizer == _panGestureRecognizer ) { if ( [_delegate respondsToSelector:@selector(revealController:panGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:)] ) { if ( [_delegate revealController:self panGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer] == YES ) return YES; } else return YES; } if ( gestureRecognizer == _tapGestureRecognizer ) { if ( [_delegate respondsToSelector:@selector(revealController:tapGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:)] ) if ( [_delegate revealController:self tapGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer] == YES ) return YES;
}
return NO; }
In my project works fine
@AntoLillo I do not get what you did. Isn't this (or similar code) implemented and working in the class already?
Thanks.
@John-Lluch Hi, I am having the same problem as described above. I have a TableView controller and the panGestureRecognizer being used and they seem to conflict. I can manage to swipe the table row but it is VERY difficult for the gesture to be recognized. My code is as follows (with irrelevant parts missed out)
`class First: UIViewController, UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func revealController(SWRevealViewController,
panGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:UIGestureRecognizer) -> Bool {
return true;
}
override func viewDidAppear(animated: Bool) {
// Create sidebar button
sidebutton.addTarget(self.revealViewController(), action:"revealToggle:", forControlEvents:UIControlEvents.TouchUpInside)
// Add gestures for sidebar functionality
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer());
}
func tableView(tableView: UITableView!, canEditRowAtIndexPath indexPath: NSIndexPath?) -> Bool {
return true
}
// Handle deleting foods via row
func tableView(tableView: UITableView!, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath!) {
//Delete method
// Any errors? - KILL IT
var error: NSError? = nil
if !context.save(&error) {
abort()
}
}
}}`
What am I doing wrong?
@rockinaway et all, I am having a hard time trying to understand the ultimate nature of this issue. You want the user to reveal the "delete" button with a pan gesture and you want her to reveal a controller also with a pan gesture?. So how is the user supposed to tell what she really means to do?
On my apps I attach the controller gesture to the navigator bar, and let table cells run their own gestures for deletes, Otherwise, what is the behavior you want to accomplish?
@John-Lluch It essentially the normal functionality. I want the pan to work as normal and show a left sidebar and then the user to left swipe on a table cell to show delete.
I have never tried putting it all in the navigator bar. Could show me an example? (sorry I'm very new to this)
Oh I see, so basically if the user swipes left you want to open "delete", if the user swipes right you want to reveal a left controller. Then you must use the hooks on the app to detect whether the initiated pan is to the left or to the right and cancel the controller. I have not tried it but you should be able to implement the revealControllerPanGestureShouldBegin to return NO (or false in swift) if we are moving left. You can use the 'translation' property of the panGestureRecognizer to determine direction.
The navigation bar approach is shown in the examples.
@John-Lluch Thanks for that reply! Would you advise to use the navigation approach so it's universally applied rather than having 'a fix' on multiple views? But yes that's the basic approach to what I want. However, if the sidebar is open then a left swipe should hide the bar. I'll look at the examples!
Edit - which example is it?
Thank you for sharing this great lib!
I have a TableView in the View. I am using native DELETE, provided by apple to delete a row. The code in ViewDidLoad is as below:
The table View Delete implementing UITableViewController delegate:
pragma mark Table Row Deleting Methods
} }
scrollPosition:UITableViewScrollPositionNone]; }
The swipe delete button does not work on TableVIEW as the Gesture is first to SWRevel.... Is there any way just for tableview the gesture will be recognized? Thanks in advance.