m1entus / MZFormSheetPresentationController

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
MIT License
974 stars 145 forks source link

Clicking on the background to dismiss the formsheetpresentationcontroller sometimes doesn't dismiss but only un-blur the background #58

Closed JosephZZ closed 8 years ago

JosephZZ commented 8 years ago

After present a view controller, and generally after I click on some parts in this presented view, and then when I click on the background, this view doesn't disappear but only causes the background from blur to clear. I saw someone else also have this problem from the older version https://github.com/m1entus/MZFormSheetController/issues/191.

m1entus commented 8 years ago

Can you prepare simple demo for that? You can have some issues in your application like keepin strong reference or something else..

JosephZZ commented 8 years ago

Before clicking the background:

screen shot 2016-02-10 at 4 13 04 pm

After clicking the background:

screen shot 2016-02-10 at 4 12 41 pm

The code is just simple code: let selectAlbumController = self.formSheetAlbumSelectionController() as! SelectAlbumTableFormSheetViewController let formSheetController = MZFormSheetPresentationViewController(contentViewController: selectAlbumController) //some more code for setting the transition effect // self.presentViewController(formSheetController, animated: true, completion: nil)

To your strong reference point, my SelectAlbumTableFormSheetViewController has a delegate variable of my own protocol, and it has IBAction and weak IBOutlet reference to it. But even if after i made the protocol weak, this problem is still there.

JosephZZ commented 8 years ago

I guess it might have to do with table view delegate. This problem would only happen if I scroll the table view up and down pretty fast. And this view would not exist no matter if I click the background or select a cell (which would trigger dismissingview function).

m1entus commented 8 years ago

I need a sample because uou could keep strong reference to some of viewController thats why it is not dismissing

JosephZZ commented 8 years ago

yeah sure. just to clarify, when you say "sample" you mean a code project that can replicate this bug?

m1entus commented 8 years ago

Yes, Short example rhat can replicate this

Nonepse commented 8 years ago

I have been encountering the same issue for a few months now. It's clearly not easy to reproduce, but I have been able to gather some info while testing my app:

Here is my code:

- (void)openProfile
{
    UIViewController *modalViewController = [[UIViewController alloc] init];

    UINavigationController *modalNavigationController = [[UINavigationController alloc]
                                                         initWithRootViewController:modalViewController];

    UIBarButtonItem *closeButton = [[UIBarButtonItem alloc]
                                    initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                                    target:self
                                    action:@selector(closeModal)];

    modalViewController.navigationItem.leftBarButtonItem = closeButton;

    MZFormSheetPresentationViewController *formSheetController =
    [[MZFormSheetPresentationViewController alloc] initWithContentViewController:modalNavigationController];

    formSheetController.interactivePanGestureDissmisalDirection = MZFormSheetPanGestureDismissDirectionAll;
    formSheetController.contentViewControllerTransitionStyle = MZFormSheetPresentationTransitionStyleSlideFromBottom;
    formSheetController.presentationController.contentViewSize = ModalSize;

    [self.navigationController presentViewController:formSheetController animated:YES completion:nil];
}

- (void)closeModal
{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

In my app, modalViewController class is a custom subclass of UIViewController. I won't put all my code here because I think it's irrelevant (and it would take pages and), but also because it's a closed-source project. Do you think it's necessary to you?

Attempts to fix it which didn't change anything:

m1entus commented 8 years ago

If you prepare some short sample project where this exist, this will be for me very super fast to try to fix that, i am lazy man, without this it could take some time to make it by myself :dancer: So please craete sample project, and i will help you guyse

Nonepse commented 8 years ago

Will do.

Nonepse commented 8 years ago

Here you go: https://cloudup.com/c4clYcQzCcc I tried to code the smallest project possible to reproduce issue.

In a simple project like that, the issue appears way less often. And since the issue happens much more rarely on simulator than on device, I have been able to reproduce it on device only (iPhone 6 in my case).

I end up with the following state (you can see the background is not dimmed) :

img_0028 copy (sorry for the poneyland colors)

In that state, the Done button does nothing, and the only way to dismiss the modal is by using a pan gesture.

m1entus commented 8 years ago

The issue is because mixing interactive and normal animator, i need more time to fix the issue. Could you tell me how to reproduce your issue (what to do) because i probably i could found another issue.

Nonepse commented 8 years ago

To reproduce the issue you have to open the modal, scroll a few times in it, then hit the Done button. It may happen once every 5 times, ad well as once every 60 times. As I said, it's hard to reproduce...

m1entus commented 8 years ago

Okay so it is the same issue, you need to in the same time click done button and try to pan to dismiss and will be reproducible, i will take care of it in some time

Nonepse commented 8 years ago

Ha, yeah you're right. If I press and hold the Done button and just after try to swipe down, release, and then hit the Done button, it happens systematically.