Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-rotation happens even when presenting controller returns 'shouldAutoRotate' as 'NO' #64

Closed
jasperblues opened this issue Oct 26, 2014 · 12 comments
Labels

Comments

@jasperblues
Copy link

Using SDCAlertView as follows, the controller that presents the alert view returns shouldAutoRotate as 'NO', however SDCAlertView sill rotates.

Is there an easy way to turn this off?

Its not possible to use SDCAlertController, as the view is being presented as follows:

  • Camera Scanning view
  • A 'frosty' overlay on the camera view. Works like [self presentViewController] except it has a custom animation on presentation, and uses UIToolbar to give a real-time iOS blur on the camera feed.

(seems SDCAlertController doesn't like the above), but SDCAlertView is happy enough, except for the minor issue of unwanted auto-rotation.

Presenting Controller

The window has been given a root view controller, in this case a dedicated one, with its view having containers matching the diagram below.

containment

  • Encapsulates app-wide UI concerns, and provides an interface for these.
  • Provides a container for application layout, and the appropriate to define custom animations for the presentation and dismissal of these views.
  • Makes UIViewContainment calls (willMoveToParentController, etc) when presenting dismissing contained views.

The implementation of shouldAutoRotate in the custom root controller is:

- (BOOL)shouldAutorotate
{
    BOOL shouldAutoRotate = NO;
    if (_overlayController) {
        if ([_overlayController isKindOfClass:[UINavigationController class]]) {
            shouldAutoRotate = [((UINavigationController *) 
                _overlayController).topViewController shouldAutorotate];

        }
        else {
            shouldAutoRotate = [_overlayController shouldAutorotate];
        }
    }
    else {
        UIViewController *topController = _navigator.topViewController;
        shouldAutoRotate = [topController shouldAutorotate];
    }
    return shouldAutoRotate;
}

. . . the above autoRotate works as expected everywhere except for the SDCAlertView that is being presented as described. Adding a debug shows that:

  • While the alert view is being presented, the first shouldAutoRotate returns the auto-rotation of _overlayController.topViewController, which is 'NO'. Yet auto-rotation still happens.
@jasperblues jasperblues changed the title Does auto-rotation even when presenting controller returns 'shouldAutoRotate' as 'NO' Auto-rotation happens even when presenting controller returns 'shouldAutoRotate' as 'NO' Oct 26, 2014
@sberrevoets
Copy link
Owner

Yeah, I see what the problem is. SDCAlertView is presented in its own window, and doesn't currently have any custom rotation behavior, which I think just means "always rotate".

Making the alert view controller have the same rotation behavior as the user window's current view controller wouldn't be too hard. The coordinator would have to figure out rotation behavior from the user window's view controller and apply it to the alert view controller as well.

I probably won't have time to look at this until next weekend, so if feel free to give it a shot if you're feeling adventurous. I can give you a few pointers if you want. Otherwise, I hope I can issue a fix next weekend.

@jasperblues
Copy link
Author

I would love to have a shot at it, but:

In terms of impact, the issue doesn't bother us too much, thought its worth mentioning hence this ticket.

@sberrevoets
Copy link
Owner

Sure, no problem! I'll get to it eventually, thanks for bringing it up.

@jasperblues
Copy link
Author

👍 Thanks again for a super useful library.

@sberrevoets
Copy link
Owner

Sure, no problem! Glad you like it.

@sberrevoets
Copy link
Owner

I tried it myself, and I believe this is fixed now. Please let me know if you're still encountering issues!

@jasperblues
Copy link
Author

Great! Verify from :head or from latest in CocoaPods mater repo?

@sberrevoets
Copy link
Owner

I haven't updated CocoaPods yet, so you'll want to pull the latest from here until CocoaPods is up to date as well.

@jasperblues
Copy link
Author

OK pod 'SDCAlertView', :head it is then.

@jasperblues
Copy link
Author

Verified here. 👍

@marcaudefroy
Copy link

Hello, soon a new pod version contains this fix?

@sberrevoets
Copy link
Owner

Yes, I'll look into updating the CocoaPods version to include this and a number of other fixes soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants