Last active
August 29, 2015 14:21
-
-
Save rshev/fbc9e21b575417263d36 to your computer and use it in GitHub Desktop.
Portrait app with rotatable players
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 | |
} | |
override func viewWillLayoutSubviews() { | |
UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment