John-Lluch / SWRevealViewController

A UIViewController subclass for presenting side view controllers inspired on the FaceBook and Wunderlist apps, done right !
Other
4.52k stars 987 forks source link

Pan - TableVIEW Delete does not work #104

Closed optme closed 10 years ago

optme commented 11 years ago

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

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.

John-Lluch commented 11 years ago

Maybe you can play with cancelsTouchesInView=NO or just avoid adding the gesture recognizer to the full view.

jyap808 commented 10 years ago

I have tested and made a pull request which fixes this issue: https://github.com/John-Lluch/SWRevealViewController/pull/143

airbob commented 10 years ago

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?

ahmetabdi commented 10 years ago

Still an ongoing issue can confirm.

pepejeria commented 10 years ago

Shouldn't this issue be reopened?

John-Lluch commented 10 years ago

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.

AntoLillo commented 10 years ago

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:

In my project works fine

John-Lluch commented 10 years ago

@AntoLillo I do not get what you did. Isn't this (or similar code) implemented and working in the class already?

Thanks.

rockinaway commented 10 years ago

@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?

John-Lluch commented 10 years ago

@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?

rockinaway commented 10 years ago

@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)

John-Lluch commented 10 years ago

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.

rockinaway commented 10 years ago

@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?