I am aware that UIActionSheet
is deprecated in iOS 8, but I still need the API because I am still targetting iOS 7.
So here's the problem: My app supports both UIInterfaceOrientationPortrait
and UIInterfaceOrientationPortraitUpsideDown
for phone devices. When my app shows a UIActionSheet
in normal portrait orientation everything is fine. If the device is turned upside down, however, the action sheet is also displayed upside down, like this:
The problem exists only when the app is run on a device (or in a simulator) with iOS 8. The problem goes away when the app is run in a simulator with iOS 7.1 (I haven't got a real device with iOS 7.1 to test). When my app was still built with a pre-iOS 8 SDK the problem also never occurred, even when the app was run on a device with iOS 8.
Does anyone have a suggestion what I could be doing wrong here? See the code snippet below for a minimal example that reproduces the problem. I am coding with Xcode 6.1.1 and iOS SDK 8.1. I promise that I haven't fiddled with the Xcode app bundle in any way :-)
Steps to reproduce the problem
doIt:
to the first responderFinally, add the following code to ViewController.m
:
- (void) doIt:(id)sender
{
UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:@"sheet title"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet addButtonWithTitle:@"sheet action"];
[actionSheet showInView:self.view];
}
// This override is required so that interface orientation
// to UIInterfaceOrientationPortraitUpsideDown is possible
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
Run the app, rotate and tap the button and you should see what I mean.
In the ios 8 , i think you had better use the UIAlertController instead. It will be better to deal with this strange case.