Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DeviceRotationOnlyOneViewController.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -288,6 +290,7 @@
1DFC394B1C8C190200D80572 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
26 changes: 13 additions & 13 deletions DeviceRotationOnlyOneViewController/AppDelegate.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
34 changes: 19 additions & 15 deletions DeviceRotationOnlyOneViewController/Base.lproj/Main.storyboard
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="14F1605" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="lrH-Ae-jsq">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="lrH-Ae-jsq">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Main-->
Expand All @@ -14,25 +18,25 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zeI-4N-2cg">
<rect key="frame" x="229" y="260" width="143" height="30"/>
<rect key="frame" x="116" y="293.5" width="143" height="30"/>
<state key="normal" title="Push View Controller"/>
<connections>
<segue destination="D7X-eA-jqO" kind="show" id="7tL-fU-ctR"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="P0P-r8-YGk">
<rect key="frame" x="219" y="310" width="162" height="30"/>
<rect key="frame" x="106.5" y="343.5" width="162" height="30"/>
<state key="normal" title="Present View Controller"/>
<connections>
<segue destination="MUM-Cp-8Gb" kind="presentation" id="Pq2-Lv-1D5"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="zeI-4N-2cg" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" constant="-25" id="0Cy-Bu-zeB"/>
<constraint firstItem="P0P-r8-YGk" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" constant="25" id="9jl-N4-o0N"/>
Expand All @@ -55,18 +59,18 @@
<viewControllerLayoutGuide type="bottom" id="trU-Lb-7LM"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="59F-nh-kDF">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hfd-tf-QIO">
<rect key="frame" x="273" y="285" width="54" height="30"/>
<rect key="frame" x="160.5" y="318.5" width="54" height="30"/>
<state key="normal" title="Dismiss"/>
<connections>
<action selector="didDismissButtonPress:" destination="MUM-Cp-8Gb" eventType="touchUpInside" id="CeM-jO-08e"/>
<action selector="didDismissWithSender:" destination="MUM-Cp-8Gb" eventType="touchUpInside" id="0er-iW-zLc"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="hfd-tf-QIO" firstAttribute="centerY" secondItem="59F-nh-kDF" secondAttribute="centerY" id="ejv-5k-ud8"/>
<constraint firstItem="hfd-tf-QIO" firstAttribute="centerX" secondItem="59F-nh-kDF" secondAttribute="centerX" id="zdf-Vo-hWS"/>
Expand All @@ -86,14 +90,14 @@
<viewControllerLayoutGuide type="bottom" id="L2A-0E-uSx"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="PcW-oQ-GSR">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="catfish" translatesAutoresizingMaskIntoConstraints="NO" id="sZ8-pU-tpa">
<rect key="frame" x="250" y="250" width="100" height="100"/>
<rect key="frame" x="137.5" y="283.5" width="100" height="100"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="sZ8-pU-tpa" firstAttribute="centerY" secondItem="PcW-oQ-GSR" secondAttribute="centerY" id="QRN-te-A18"/>
<constraint firstItem="sZ8-pU-tpa" firstAttribute="centerX" secondItem="PcW-oQ-GSR" secondAttribute="centerX" id="wPa-Ps-8tv"/>
Expand All @@ -111,7 +115,7 @@
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="lrH-Ae-jsq" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="qcC-oS-IxE">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand Down
Empty file modified DeviceRotationOnlyOneViewController/Info.plist
100644 → 100755
Empty file.
10 changes: 4 additions & 6 deletions DeviceRotationOnlyOneViewController/PresentedViewController.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
16 changes: 9 additions & 7 deletions DeviceRotationOnlyOneViewController/ViewController.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
Empty file modified README.md
100644 → 100755
Empty file.