Skip to content

Instantly share code, notes, and snippets.

@mkeremkeskin
Created April 16, 2015 21:13
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mkeremkeskin/0ed9fc4a2c0e4942e451 to your computer and use it in GitHub Desktop.
Save mkeremkeskin/0ed9fc4a2c0e4942e451 to your computer and use it in GitHub Desktop.
iOS 8.3 UIAlertController orientation bug
#import <UIKit/UIKit.h>
@interface UIAlertController (Orientation)
@end
#import "UIAlertController+Orientation.h"
@implementation UIAlertController(Orientation)
#pragma mark self rotate
- (BOOL)shouldAutorotate {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if ( orientation == UIDeviceOrientationPortrait
| orientation == UIDeviceOrientationPortraitUpsideDown) {
return YES;
}
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
UIDevice* device = [UIDevice currentDevice];
if (device.orientation == UIInterfaceOrientationPortraitUpsideDown) {
return UIInterfaceOrientationPortraitUpsideDown;
}
return UIInterfaceOrientationPortrait;
}
@end
@sydhassan
Copy link

can you help me how can i use this after including this files in my project what i have to do, thanks in advance, and sorry i am also a new in iOS

@mkeremkeskin
Copy link
Author

just import UIAlertController+Orientation.h to the class where you are using UIAlertController.

@MohanKumarIOS
Copy link

Its possible change the Portrait to landscape in UIAlertviewController. i Had used third party library ,there one uialerview showing portrait but our app show in landscape i want change portrait to landscape uialertview.

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