Skip to content

Instantly share code, notes, and snippets.

@rshev
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save rshev/fbc9e21b575417263d36 to your computer and use it in GitHub Desktop.

Select an option

Save rshev/fbc9e21b575417263d36 to your computer and use it in GitHub Desktop.

Revisions

  1. rshev revised this gist May 20, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions portrait_with_rotatable_players.swift
    Original file line number Diff line number Diff line change
    @@ -40,3 +40,8 @@ public extension NSObject{
    override func shouldAutorotate() -> Bool {
    return false
    }

    override func viewWillLayoutSubviews() {
    UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)
    }

  2. rshev renamed this gist May 20, 2015. 1 changed file with 0 additions and 0 deletions.
  3. rshev renamed this gist May 20, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. rshev revised this gist May 20, 2015. No changes.
  5. rshev created this gist May 20, 2015.
    42 changes: 42 additions & 0 deletions gistfile1.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    //AppDelegate:
    func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> Int {

    var presentedVC = application.keyWindow?.rootViewController
    while let pVC = presentedVC?.presentedViewController
    {
    presentedVC = pVC
    }
    if let pVC = presentedVC
    {
    if contains(["MPInlineVideoFullscreenViewController", "MPMoviePlayerViewController", "AVFullScreenViewController"], pVC.nameOfClass)
    {
    return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
    }
    }

    return Int(UIInterfaceOrientationMask.Portrait.rawValue)
    }

    //Extension:
    public extension NSObject{
    public class var nameOfClass: String{
    return NSStringFromClass(self).componentsSeparatedByString(".").last!
    }

    public var nameOfClass: String{
    return NSStringFromClass(self.dynamicType).componentsSeparatedByString(".").last!
    }
    }

    //View controller:
    override func supportedInterfaceOrientations() -> Int {
    return Int(UIInterfaceOrientationMask.Portrait.rawValue)
    }

    override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
    return UIInterfaceOrientation.Portrait
    }

    override func shouldAutorotate() -> Bool {
    return false
    }