Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. extension UIAlertController {
  2. public override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
  3. return UIInterfaceOrientationMask.Portrait
  4. }
  5. public override func shouldAutorotate() -> Bool {
  6. return false
  7. }
  8. }
  9.  
  10. extension UIAlertController {
  11. open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
  12. return UIInterfaceOrientationMask.portrait
  13. }
  14. open override var shouldAutorotate: Bool {
  15. return false
  16. }
  17. }
  18.  
  19. //
  20. // UIAlertController+supportedInterfaceOrientations.h
  21.  
  22. #import <UIKit/UIKit.h>
  23. @interface UIAlertController (supportedInterfaceOrientations)
  24. @end
  25.  
  26. //
  27. // UIAlertController+supportedInterfaceOrientations.m
  28.  
  29. #import "UIAlertController+supportedInterfaceOrientations.h"
  30.  
  31. @implementation UIAlertController (supportedInterfaceOrientations)
  32.  
  33. #if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
  34. - (NSUInteger)supportedInterfaceOrientations {
  35. return UIInterfaceOrientationMaskPortrait;
  36. }
  37. #else
  38. - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  39. return UIInterfaceOrientationMaskPortrait;
  40. }
  41. #endif
  42.  
  43. @end
  44.  
  45. extension UIAlertController {
  46.  
  47. public override func shouldAutorotate() -> Bool {
  48. return true
  49. }
  50.  
  51. public override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
  52. return UIInterfaceOrientationMask.All
  53. }
  54. }
  55.  
  56. class MyUIAlertController : UIAlertController {
  57.  
  58. override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
  59. return [UIInterfaceOrientationMask.Portrait,UIInterfaceOrientationMask.PortraitUpsideDown]
  60. }
  61.  
  62. override func shouldAutorotate() -> Bool {
  63. return false
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement