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

Picker rotating when host view controller fixed to portrait #100

Closed
jonathan2708 opened this issue Nov 21, 2014 · 22 comments
Closed

Picker rotating when host view controller fixed to portrait #100

jonathan2708 opened this issue Nov 21, 2014 · 22 comments

Comments

@jonathan2708
Copy link

In my app target settings I've ticked all orientations except for 'Upside Down'. In most view controllers I've limited the orientation to 'Portrait' by using the following code :

-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

This locks the view controller to portrait, but the ActionSheetPicker doesn't respect this and animates itself to landscape when the device is rotated. It also has the effect of taking the status bar with it so this ends up displayed along the long edge of the phone.

How should I use the control so that it either locks to portrait, or dismisses when the device is rotated? I'm building with Xcode 6/iOS 8 SDK.

@skywinder skywinder added the bug label Nov 21, 2014
@skywinder
Copy link
Owner

Hi. Now you can't do anything with orientation of the picker. And it's really can cause problems.
In the way to resolve this issue - it's needed to implement additional property for picker, to specify orientations, that it should support. I will try to fix it soon.

@skywinder
Copy link
Owner

Fixed. I add property supportedInterfaceOrientations.
Now you can specify what orientations you would like to support.

@jonathan2708
Copy link
Author

Hi, I'm trying to use this new property by setting it to UIInterfaceOrientationMaskPortrait but I'm still getting the same animation effect when the device is rotated. Am I doing something wrong? How can the picker be locked for rotation? I've updated to version 1.3.10.

@skywinder skywinder reopened this Jan 16, 2015
@skywinder
Copy link
Owner

@jonathan2708 ok, I reopen issue. I try to fix it soon.
Can you show me example of code, how you init picker and set supportedInterfaceOrientations property?

@jonathan2708
Copy link
Author

Hi, many thanks for looking into this. I've pasted the code I'm using below, and included a screenshot too.

ActionSheetDatePicker *datePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Select Date" datePickerMode:UIDatePickerModeDate selectedDate:defaultDate target:self action:@selector(dateWasSelected:element:) origin:sender];
[datePicker setSupportedInterfaceOrientations:UIInterfaceOrientationMaskPortrait];
[datePicker setDoneButton:btnPickerDone];
[datePicker setCancelButton:btnPickerCancel];
[datePicker showActionSheetPicker];

ios simulator screen shot 16 jan 2015 21 49 05

@ralito
Copy link

ralito commented Jan 21, 2015

I am having the exact same problem. The picker is ignoring the value that is set to supportedInterfaceOrientations property.

@Morpheus2002
Copy link

+1

@skywinder
Copy link
Owner

@ralito , @Morpheus2002 Can't reproduce, thus can't fix it. Can you give me more info, how to reproduce it?

@Morpheus2002
Copy link

I locked the presenting view to portrait mode with this functions:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

- (NSUInteger)supportedInterfaceOrientations
{
        return UIInterfaceOrientationMaskPortrait;
}


- (BOOL)shouldAutorotate
{
    return NO;   
}

As on the screenshot above from @jonathan2708 the app itself stays in portrait mode, but the picker view is rotated and loses background color.

Not using

[datePicker setSupportedInterfaceOrientations:UIInterfaceOrientationMaskPortrait];

@skywinder
Copy link
Owner

@jonathan2708 , @ralito , @Morpheus2002 fixed in 1.5.0

@gabula80
Copy link

gabula80 commented Mar 6, 2015

The issue still persists. Scenario to reproduce:

  • Lock the interface in UIViewController to Portrait by overriding supportedInterfaceOrientations and returning UIInterfaceOrientationMaskPortrait.
  • Set the picker to supportedInterfaceOrientations to Portrait using set setSupportedInterfaceOrientations. Note that it is reproducible with both this property set and not set.
  • Leave the phone in portrait and perform the action that opens the picker (like pressing a button).
  • Rotate to landscape. The ViewController will not rotate and remain in portrait, but the picker will rotate and mess up its background as shown in the pic from @jonathan2708

@jonathan2708
Copy link
Author

I agree with @gabula80 - still not fixed in 1.5.0. As a temporary fix for my portrait-only app I have made the following change to SWActionSheet.m :

-(NSUInteger)supportedInterfaceOrientations {
    //return UIInterfaceOrientationMaskAll;
    return UIInterfaceOrientationMaskPortrait;
}

@skywinder skywinder reopened this Mar 6, 2015
@skywinder
Copy link
Owner

Ok, I reopen this issue.

@skywinder skywinder removed this from the 1.3.6 milestone Mar 6, 2015
@ralito
Copy link

ralito commented Mar 12, 2015

Since my app support all interface orientations for iPad and only Portrait for iPhone as a temporary solution in the SWActionSheet.m I implemented :

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  • (NSUInteger)supportedInterfaceOrientations

I hope this helps someone. :)

@tbaranes
Copy link

Same issue here. The picker is dismissed well when I'm rotating, but the application is rotating anyway. I didn't look too deep, but this looks weir for me in SWActionSheet:

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

That should return the orientation set in the application / AbstractActionSheetPicker to respect the orientation setup, isn't it?

@skywinder
Copy link
Owner

@tbaranes the main point is detect orientation of application. and dismiss picker only when application is willRotate. I didn't find clean solution yet.

@tbaranes
Copy link

Should the picker really be dismissed? I mean, if the orientation isn't available for the device, the picker should just stay open in place like the rest of the application. It should be the developer's choice to dismiss it or not following the case.

Moreover, that would probably make easier to solve this issue.

@skywinder
Copy link
Owner

@tbaranes I like the way you think. 👍 This behaviour looks logically and clear.

@pahnev
Copy link

pahnev commented Oct 22, 2015

I believe this bug has made it's way back.

@FedericoHenze
Copy link

This is still happening, how is the appropriate way to avoid the rotation of the picker?

@jignesh133
Copy link

jignesh133 commented Sep 1, 2017

i am not able to change the cancel and Done buttons colour,and picker text colour.
image

@MyNameIsWood
Copy link

@jonathan2708
paste the following code in SWActionSheetVC/@implementation SWActionSheetVC:
`- (UIInterfaceOrientationMask)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskPortrait;

}
`

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

No branches or pull requests

10 participants