From b57047ce26c39993bd8129b875ad570db630bcda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Gleb=20Tarasov?= Date: Mon, 27 Nov 2017 15:01:04 +0300 Subject: [PATCH] Swift4 support --- .../project.pbxproj | 3 ++ .../contents.xcworkspacedata | 0 .../UserInterfaceState.xcuserstate | Bin .../xcdebugger/Breakpoints_v2.xcbkptlist | 0 ...viceRotationOnlyOneViewController.xcscheme | 0 .../xcschemes/xcschememanagement.plist | 0 .../AppDelegate.swift | 26 +++++++------- .../AppIcon.appiconset/Contents.json | 0 .../Assets.xcassets/Contents.json | 0 .../catfish.imageset/6944252.png | Bin .../catfish.imageset/Contents.json | 0 .../Base.lproj/LaunchScreen.storyboard | 0 .../Base.lproj/Main.storyboard | 34 ++++++++++-------- .../Info.plist | 0 .../PresentedViewController.swift | 10 +++--- .../ViewController.swift | 16 +++++---- README.md | 0 17 files changed, 48 insertions(+), 41 deletions(-) mode change 100644 => 100755 DeviceRotationOnlyOneViewController.xcodeproj/project.pbxproj mode change 100644 => 100755 DeviceRotationOnlyOneViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata mode change 100644 => 100755 DeviceRotationOnlyOneViewController.xcodeproj/project.xcworkspace/xcuserdata/jairobjunior.xcuserdatad/UserInterfaceState.xcuserstate mode change 100644 => 100755 DeviceRotationOnlyOneViewController.xcodeproj/xcuserdata/jairobjunior.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist mode change 100644 => 100755 DeviceRotationOnlyOneViewController.xcodeproj/xcuserdata/jairobjunior.xcuserdatad/xcschemes/DeviceRotationOnlyOneViewController.xcscheme mode change 100644 => 100755 DeviceRotationOnlyOneViewController.xcodeproj/xcuserdata/jairobjunior.xcuserdatad/xcschemes/xcschememanagement.plist mode change 100644 => 100755 DeviceRotationOnlyOneViewController/AppDelegate.swift mode change 100644 => 100755 DeviceRotationOnlyOneViewController/Assets.xcassets/AppIcon.appiconset/Contents.json mode change 100644 => 100755 DeviceRotationOnlyOneViewController/Assets.xcassets/Contents.json mode change 100644 => 100755 DeviceRotationOnlyOneViewController/Assets.xcassets/catfish.imageset/6944252.png mode change 100644 => 100755 DeviceRotationOnlyOneViewController/Assets.xcassets/catfish.imageset/Contents.json mode change 100644 => 100755 DeviceRotationOnlyOneViewController/Base.lproj/LaunchScreen.storyboard mode change 100644 => 100755 DeviceRotationOnlyOneViewController/Base.lproj/Main.storyboard mode change 100644 => 100755 DeviceRotationOnlyOneViewController/Info.plist mode change 100644 => 100755 DeviceRotationOnlyOneViewController/PresentedViewController.swift mode change 100644 => 100755 DeviceRotationOnlyOneViewController/ViewController.swift mode change 100644 => 100755 README.md diff --git a/DeviceRotationOnlyOneViewController.xcodeproj/project.pbxproj b/DeviceRotationOnlyOneViewController.xcodeproj/project.pbxproj old mode 100644 new mode 100755 index ff3d134..41162a1 --- a/DeviceRotationOnlyOneViewController.xcodeproj/project.pbxproj +++ b/DeviceRotationOnlyOneViewController.xcodeproj/project.pbxproj @@ -255,6 +255,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.jairobjunior.DeviceRotationOnlyOneViewController; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -266,6 +267,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.jairobjunior.DeviceRotationOnlyOneViewController; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -288,6 +290,7 @@ 1DFC394B1C8C190200D80572 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/DeviceRotationOnlyOneViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/DeviceRotationOnlyOneViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController.xcodeproj/project.xcworkspace/xcuserdata/jairobjunior.xcuserdatad/UserInterfaceState.xcuserstate b/DeviceRotationOnlyOneViewController.xcodeproj/project.xcworkspace/xcuserdata/jairobjunior.xcuserdatad/UserInterfaceState.xcuserstate old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController.xcodeproj/xcuserdata/jairobjunior.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/DeviceRotationOnlyOneViewController.xcodeproj/xcuserdata/jairobjunior.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController.xcodeproj/xcuserdata/jairobjunior.xcuserdatad/xcschemes/DeviceRotationOnlyOneViewController.xcscheme b/DeviceRotationOnlyOneViewController.xcodeproj/xcuserdata/jairobjunior.xcuserdatad/xcschemes/DeviceRotationOnlyOneViewController.xcscheme old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController.xcodeproj/xcuserdata/jairobjunior.xcuserdatad/xcschemes/xcschememanagement.plist b/DeviceRotationOnlyOneViewController.xcodeproj/xcuserdata/jairobjunior.xcuserdatad/xcschemes/xcschememanagement.plist old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController/AppDelegate.swift b/DeviceRotationOnlyOneViewController/AppDelegate.swift old mode 100644 new mode 100755 index 6dd6aae..41e7287 --- a/DeviceRotationOnlyOneViewController/AppDelegate.swift +++ b/DeviceRotationOnlyOneViewController/AppDelegate.swift @@ -14,50 +14,50 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - func applicationDidBecomeActive(application: UIApplication) { + func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } - func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask { + func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { if let rootViewController = self.topViewControllerWithRootViewController(window?.rootViewController) { - if (rootViewController.respondsToSelector(Selector("canRotate"))) { + if (rootViewController is CanRotate) { // Unlock landscape view orientations for this view controller - return .AllButUpsideDown; + return .allButUpsideDown; } } // Only allow portrait (standard behaviour) - return .Portrait; + return .portrait; } - private func topViewControllerWithRootViewController(rootViewController: UIViewController!) -> UIViewController? { + private func topViewControllerWithRootViewController(_ rootViewController: UIViewController!) -> UIViewController? { if (rootViewController == nil) { return nil } - if (rootViewController.isKindOfClass(UITabBarController)) { + if (rootViewController is UITabBarController) { return topViewControllerWithRootViewController((rootViewController as! UITabBarController).selectedViewController) - } else if (rootViewController.isKindOfClass(UINavigationController)) { + } else if (rootViewController is UINavigationController) { return topViewControllerWithRootViewController((rootViewController as! UINavigationController).visibleViewController) } else if (rootViewController.presentedViewController != nil) { return topViewControllerWithRootViewController(rootViewController.presentedViewController) diff --git a/DeviceRotationOnlyOneViewController/Assets.xcassets/AppIcon.appiconset/Contents.json b/DeviceRotationOnlyOneViewController/Assets.xcassets/AppIcon.appiconset/Contents.json old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController/Assets.xcassets/Contents.json b/DeviceRotationOnlyOneViewController/Assets.xcassets/Contents.json old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController/Assets.xcassets/catfish.imageset/6944252.png b/DeviceRotationOnlyOneViewController/Assets.xcassets/catfish.imageset/6944252.png old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController/Assets.xcassets/catfish.imageset/Contents.json b/DeviceRotationOnlyOneViewController/Assets.xcassets/catfish.imageset/Contents.json old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController/Base.lproj/LaunchScreen.storyboard b/DeviceRotationOnlyOneViewController/Base.lproj/LaunchScreen.storyboard old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController/Base.lproj/Main.storyboard b/DeviceRotationOnlyOneViewController/Base.lproj/Main.storyboard old mode 100644 new mode 100755 index a270c2f..0cc5bfc --- a/DeviceRotationOnlyOneViewController/Base.lproj/Main.storyboard +++ b/DeviceRotationOnlyOneViewController/Base.lproj/Main.storyboard @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -14,25 +18,25 @@ - + - + @@ -55,18 +59,18 @@ - + - + @@ -86,14 +90,14 @@ - + - + - + @@ -111,7 +115,7 @@ - + diff --git a/DeviceRotationOnlyOneViewController/Info.plist b/DeviceRotationOnlyOneViewController/Info.plist old mode 100644 new mode 100755 diff --git a/DeviceRotationOnlyOneViewController/PresentedViewController.swift b/DeviceRotationOnlyOneViewController/PresentedViewController.swift old mode 100644 new mode 100755 index b7c5092..6bdb7bc --- a/DeviceRotationOnlyOneViewController/PresentedViewController.swift +++ b/DeviceRotationOnlyOneViewController/PresentedViewController.swift @@ -8,18 +8,16 @@ import UIKit -class PresentedViewController: UIViewController { +class PresentedViewController: UIViewController, CanRotate { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } - @IBAction func didDismissButtonPress(sender: UIButton) { - self.dismissViewControllerAnimated(true) { () -> Void in - UIDevice.currentDevice().setValue(Int(UIInterfaceOrientation.Portrait.rawValue), forKey: "orientation") + @IBAction func didDismiss(sender: UIButton) { + self.dismiss(animated: true) { () -> Void in + UIDevice.current.setValue(Int(UIInterfaceOrientation.portrait.rawValue), forKey: "orientation") } } - - func canRotate() -> Void {} } diff --git a/DeviceRotationOnlyOneViewController/ViewController.swift b/DeviceRotationOnlyOneViewController/ViewController.swift old mode 100644 new mode 100755 index 0a7276a..33ace51 --- a/DeviceRotationOnlyOneViewController/ViewController.swift +++ b/DeviceRotationOnlyOneViewController/ViewController.swift @@ -8,20 +8,22 @@ import UIKit -class ViewController: UIViewController { +protocol CanRotate: class { + +} + +class ViewController: UIViewController, CanRotate { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } - - override func viewWillDisappear(animated : Bool) { + + override func viewWillDisappear(_ animated : Bool) { super.viewWillDisappear(animated) - if (self.isMovingFromParentViewController()) { - UIDevice.currentDevice().setValue(Int(UIInterfaceOrientation.Portrait.rawValue), forKey: "orientation") + if (self.isMovingFromParentViewController) { + UIDevice.current.setValue(Int(UIInterfaceOrientation.portrait.rawValue), forKey: "orientation") } } - - func canRotate() -> Void {} } diff --git a/README.md b/README.md old mode 100644 new mode 100755