├── LICENSE ├── MXRotationManager.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── michael.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── michael.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── MXRotationManager ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── MXRotationManager │ ├── MXRotationManager.h │ └── MXRotationManager.m ├── ViewController.h ├── ViewController.m └── main.m └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Michael 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MXRotationManager.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4C5A298421AD2763009FA289 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5A298321AD2763009FA289 /* AppDelegate.m */; }; 11 | 4C5A298721AD2763009FA289 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5A298621AD2763009FA289 /* ViewController.m */; }; 12 | 4C5A298A21AD2763009FA289 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4C5A298821AD2763009FA289 /* Main.storyboard */; }; 13 | 4C5A298C21AD2764009FA289 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4C5A298B21AD2764009FA289 /* Assets.xcassets */; }; 14 | 4C5A298F21AD2764009FA289 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4C5A298D21AD2764009FA289 /* LaunchScreen.storyboard */; }; 15 | 4C5A299221AD2764009FA289 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5A299121AD2764009FA289 /* main.m */; }; 16 | 4C5A299B21AD278E009FA289 /* MXRotationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5A299921AD278E009FA289 /* MXRotationManager.m */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 4C5A297F21AD2763009FA289 /* MXRotationManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MXRotationManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 4C5A298221AD2763009FA289 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 22 | 4C5A298321AD2763009FA289 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 23 | 4C5A298521AD2763009FA289 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 24 | 4C5A298621AD2763009FA289 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 25 | 4C5A298921AD2763009FA289 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 4C5A298B21AD2764009FA289 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | 4C5A298E21AD2764009FA289 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 4C5A299021AD2764009FA289 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | 4C5A299121AD2764009FA289 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 30 | 4C5A299921AD278E009FA289 /* MXRotationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXRotationManager.m; sourceTree = ""; }; 31 | 4C5A299A21AD278E009FA289 /* MXRotationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXRotationManager.h; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | 4C5A297C21AD2763009FA289 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 4C5A297621AD2763009FA289 = { 46 | isa = PBXGroup; 47 | children = ( 48 | 4C5A298121AD2763009FA289 /* MXRotationManager */, 49 | 4C5A298021AD2763009FA289 /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 4C5A298021AD2763009FA289 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 4C5A297F21AD2763009FA289 /* MXRotationManager.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 4C5A298121AD2763009FA289 /* MXRotationManager */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 4C5A299821AD278E009FA289 /* MXRotationManager */, 65 | 4C5A298221AD2763009FA289 /* AppDelegate.h */, 66 | 4C5A298321AD2763009FA289 /* AppDelegate.m */, 67 | 4C5A298521AD2763009FA289 /* ViewController.h */, 68 | 4C5A298621AD2763009FA289 /* ViewController.m */, 69 | 4C5A298821AD2763009FA289 /* Main.storyboard */, 70 | 4C5A298B21AD2764009FA289 /* Assets.xcassets */, 71 | 4C5A298D21AD2764009FA289 /* LaunchScreen.storyboard */, 72 | 4C5A299021AD2764009FA289 /* Info.plist */, 73 | 4C5A299121AD2764009FA289 /* main.m */, 74 | ); 75 | path = MXRotationManager; 76 | sourceTree = ""; 77 | }; 78 | 4C5A299821AD278E009FA289 /* MXRotationManager */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 4C5A299921AD278E009FA289 /* MXRotationManager.m */, 82 | 4C5A299A21AD278E009FA289 /* MXRotationManager.h */, 83 | ); 84 | path = MXRotationManager; 85 | sourceTree = ""; 86 | }; 87 | /* End PBXGroup section */ 88 | 89 | /* Begin PBXNativeTarget section */ 90 | 4C5A297E21AD2763009FA289 /* MXRotationManager */ = { 91 | isa = PBXNativeTarget; 92 | buildConfigurationList = 4C5A299521AD2764009FA289 /* Build configuration list for PBXNativeTarget "MXRotationManager" */; 93 | buildPhases = ( 94 | 4C5A297B21AD2763009FA289 /* Sources */, 95 | 4C5A297C21AD2763009FA289 /* Frameworks */, 96 | 4C5A297D21AD2763009FA289 /* Resources */, 97 | ); 98 | buildRules = ( 99 | ); 100 | dependencies = ( 101 | ); 102 | name = MXRotationManager; 103 | productName = MXRotationManager; 104 | productReference = 4C5A297F21AD2763009FA289 /* MXRotationManager.app */; 105 | productType = "com.apple.product-type.application"; 106 | }; 107 | /* End PBXNativeTarget section */ 108 | 109 | /* Begin PBXProject section */ 110 | 4C5A297721AD2763009FA289 /* Project object */ = { 111 | isa = PBXProject; 112 | attributes = { 113 | LastUpgradeCheck = 1010; 114 | ORGANIZATIONNAME = Michael; 115 | TargetAttributes = { 116 | 4C5A297E21AD2763009FA289 = { 117 | CreatedOnToolsVersion = 10.1; 118 | }; 119 | }; 120 | }; 121 | buildConfigurationList = 4C5A297A21AD2763009FA289 /* Build configuration list for PBXProject "MXRotationManager" */; 122 | compatibilityVersion = "Xcode 9.3"; 123 | developmentRegion = en; 124 | hasScannedForEncodings = 0; 125 | knownRegions = ( 126 | en, 127 | Base, 128 | ); 129 | mainGroup = 4C5A297621AD2763009FA289; 130 | productRefGroup = 4C5A298021AD2763009FA289 /* Products */; 131 | projectDirPath = ""; 132 | projectRoot = ""; 133 | targets = ( 134 | 4C5A297E21AD2763009FA289 /* MXRotationManager */, 135 | ); 136 | }; 137 | /* End PBXProject section */ 138 | 139 | /* Begin PBXResourcesBuildPhase section */ 140 | 4C5A297D21AD2763009FA289 /* Resources */ = { 141 | isa = PBXResourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | 4C5A298F21AD2764009FA289 /* LaunchScreen.storyboard in Resources */, 145 | 4C5A298C21AD2764009FA289 /* Assets.xcassets in Resources */, 146 | 4C5A298A21AD2763009FA289 /* Main.storyboard in Resources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXResourcesBuildPhase section */ 151 | 152 | /* Begin PBXSourcesBuildPhase section */ 153 | 4C5A297B21AD2763009FA289 /* Sources */ = { 154 | isa = PBXSourcesBuildPhase; 155 | buildActionMask = 2147483647; 156 | files = ( 157 | 4C5A298721AD2763009FA289 /* ViewController.m in Sources */, 158 | 4C5A299221AD2764009FA289 /* main.m in Sources */, 159 | 4C5A299B21AD278E009FA289 /* MXRotationManager.m in Sources */, 160 | 4C5A298421AD2763009FA289 /* AppDelegate.m in Sources */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | /* End PBXSourcesBuildPhase section */ 165 | 166 | /* Begin PBXVariantGroup section */ 167 | 4C5A298821AD2763009FA289 /* Main.storyboard */ = { 168 | isa = PBXVariantGroup; 169 | children = ( 170 | 4C5A298921AD2763009FA289 /* Base */, 171 | ); 172 | name = Main.storyboard; 173 | sourceTree = ""; 174 | }; 175 | 4C5A298D21AD2764009FA289 /* LaunchScreen.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | 4C5A298E21AD2764009FA289 /* Base */, 179 | ); 180 | name = LaunchScreen.storyboard; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXVariantGroup section */ 184 | 185 | /* Begin XCBuildConfiguration section */ 186 | 4C5A299321AD2764009FA289 /* Debug */ = { 187 | isa = XCBuildConfiguration; 188 | buildSettings = { 189 | ALWAYS_SEARCH_USER_PATHS = NO; 190 | CLANG_ANALYZER_NONNULL = YES; 191 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 192 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 193 | CLANG_CXX_LIBRARY = "libc++"; 194 | CLANG_ENABLE_MODULES = YES; 195 | CLANG_ENABLE_OBJC_ARC = YES; 196 | CLANG_ENABLE_OBJC_WEAK = YES; 197 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 198 | CLANG_WARN_BOOL_CONVERSION = YES; 199 | CLANG_WARN_COMMA = YES; 200 | CLANG_WARN_CONSTANT_CONVERSION = YES; 201 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 202 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 203 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 204 | CLANG_WARN_EMPTY_BODY = YES; 205 | CLANG_WARN_ENUM_CONVERSION = YES; 206 | CLANG_WARN_INFINITE_RECURSION = YES; 207 | CLANG_WARN_INT_CONVERSION = YES; 208 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 209 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 210 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 211 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 212 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 213 | CLANG_WARN_STRICT_PROTOTYPES = YES; 214 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 215 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 216 | CLANG_WARN_UNREACHABLE_CODE = YES; 217 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 218 | CODE_SIGN_IDENTITY = "iPhone Developer"; 219 | COPY_PHASE_STRIP = NO; 220 | DEBUG_INFORMATION_FORMAT = dwarf; 221 | ENABLE_STRICT_OBJC_MSGSEND = YES; 222 | ENABLE_TESTABILITY = YES; 223 | GCC_C_LANGUAGE_STANDARD = gnu11; 224 | GCC_DYNAMIC_NO_PIC = NO; 225 | GCC_NO_COMMON_BLOCKS = YES; 226 | GCC_OPTIMIZATION_LEVEL = 0; 227 | GCC_PREPROCESSOR_DEFINITIONS = ( 228 | "DEBUG=1", 229 | "$(inherited)", 230 | ); 231 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 232 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 233 | GCC_WARN_UNDECLARED_SELECTOR = YES; 234 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 235 | GCC_WARN_UNUSED_FUNCTION = YES; 236 | GCC_WARN_UNUSED_VARIABLE = YES; 237 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 238 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 239 | MTL_FAST_MATH = YES; 240 | ONLY_ACTIVE_ARCH = YES; 241 | SDKROOT = iphoneos; 242 | }; 243 | name = Debug; 244 | }; 245 | 4C5A299421AD2764009FA289 /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | CLANG_ANALYZER_NONNULL = YES; 250 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 252 | CLANG_CXX_LIBRARY = "libc++"; 253 | CLANG_ENABLE_MODULES = YES; 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | CLANG_ENABLE_OBJC_WEAK = YES; 256 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_COMMA = YES; 259 | CLANG_WARN_CONSTANT_CONVERSION = YES; 260 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 263 | CLANG_WARN_EMPTY_BODY = YES; 264 | CLANG_WARN_ENUM_CONVERSION = YES; 265 | CLANG_WARN_INFINITE_RECURSION = YES; 266 | CLANG_WARN_INT_CONVERSION = YES; 267 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 269 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 272 | CLANG_WARN_STRICT_PROTOTYPES = YES; 273 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 274 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | CODE_SIGN_IDENTITY = "iPhone Developer"; 278 | COPY_PHASE_STRIP = NO; 279 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 280 | ENABLE_NS_ASSERTIONS = NO; 281 | ENABLE_STRICT_OBJC_MSGSEND = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu11; 283 | GCC_NO_COMMON_BLOCKS = YES; 284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 286 | GCC_WARN_UNDECLARED_SELECTOR = YES; 287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 288 | GCC_WARN_UNUSED_FUNCTION = YES; 289 | GCC_WARN_UNUSED_VARIABLE = YES; 290 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 291 | MTL_ENABLE_DEBUG_INFO = NO; 292 | MTL_FAST_MATH = YES; 293 | SDKROOT = iphoneos; 294 | VALIDATE_PRODUCT = YES; 295 | }; 296 | name = Release; 297 | }; 298 | 4C5A299621AD2764009FA289 /* Debug */ = { 299 | isa = XCBuildConfiguration; 300 | buildSettings = { 301 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 302 | CODE_SIGN_STYLE = Automatic; 303 | DEVELOPMENT_TEAM = YP4RBV4SRC; 304 | INFOPLIST_FILE = MXRotationManager/Info.plist; 305 | LD_RUNPATH_SEARCH_PATHS = ( 306 | "$(inherited)", 307 | "@executable_path/Frameworks", 308 | ); 309 | PRODUCT_BUNDLE_IDENTIFIER = com.Yunlu.MXRotationManager; 310 | PRODUCT_NAME = "$(TARGET_NAME)"; 311 | TARGETED_DEVICE_FAMILY = "1,2"; 312 | }; 313 | name = Debug; 314 | }; 315 | 4C5A299721AD2764009FA289 /* Release */ = { 316 | isa = XCBuildConfiguration; 317 | buildSettings = { 318 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 319 | CODE_SIGN_STYLE = Automatic; 320 | DEVELOPMENT_TEAM = YP4RBV4SRC; 321 | INFOPLIST_FILE = MXRotationManager/Info.plist; 322 | LD_RUNPATH_SEARCH_PATHS = ( 323 | "$(inherited)", 324 | "@executable_path/Frameworks", 325 | ); 326 | PRODUCT_BUNDLE_IDENTIFIER = com.Yunlu.MXRotationManager; 327 | PRODUCT_NAME = "$(TARGET_NAME)"; 328 | TARGETED_DEVICE_FAMILY = "1,2"; 329 | }; 330 | name = Release; 331 | }; 332 | /* End XCBuildConfiguration section */ 333 | 334 | /* Begin XCConfigurationList section */ 335 | 4C5A297A21AD2763009FA289 /* Build configuration list for PBXProject "MXRotationManager" */ = { 336 | isa = XCConfigurationList; 337 | buildConfigurations = ( 338 | 4C5A299321AD2764009FA289 /* Debug */, 339 | 4C5A299421AD2764009FA289 /* Release */, 340 | ); 341 | defaultConfigurationIsVisible = 0; 342 | defaultConfigurationName = Release; 343 | }; 344 | 4C5A299521AD2764009FA289 /* Build configuration list for PBXNativeTarget "MXRotationManager" */ = { 345 | isa = XCConfigurationList; 346 | buildConfigurations = ( 347 | 4C5A299621AD2764009FA289 /* Debug */, 348 | 4C5A299721AD2764009FA289 /* Release */, 349 | ); 350 | defaultConfigurationIsVisible = 0; 351 | defaultConfigurationName = Release; 352 | }; 353 | /* End XCConfigurationList section */ 354 | }; 355 | rootObject = 4C5A297721AD2763009FA289 /* Project object */; 356 | } 357 | -------------------------------------------------------------------------------- /MXRotationManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MXRotationManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MXRotationManager.xcodeproj/project.xcworkspace/xcuserdata/michael.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michaelxiaonull/MXRotationManager/7ea1a53b0090b23a8bfe57a3fdf9c27e7367a30a/MXRotationManager.xcodeproj/project.xcworkspace/xcuserdata/michael.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MXRotationManager.xcodeproj/xcuserdata/michael.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /MXRotationManager.xcodeproj/xcuserdata/michael.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MXRotationManager.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /MXRotationManager/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MXRotationManager 4 | // 5 | // Created by Michael on 2018/11/27. 6 | // Copyright © 2018 Michael. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MXRotationManager/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MXRotationManager 4 | // 5 | // Created by Michael on 2018/11/27. 6 | // Copyright © 2018 Michael. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "MXRotationManager.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | #pragma mark - add method 19 | - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 20 | return [MXRotationManager defaultManager].interfaceOrientationMask; 21 | } 22 | 23 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 24 | return YES; 25 | } 26 | 27 | 28 | - (void)applicationWillResignActive:(UIApplication *)application { 29 | // 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. 30 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 31 | } 32 | 33 | 34 | - (void)applicationDidEnterBackground:(UIApplication *)application { 35 | // 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. 36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 37 | } 38 | 39 | 40 | - (void)applicationWillEnterForeground:(UIApplication *)application { 41 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 42 | } 43 | 44 | 45 | - (void)applicationDidBecomeActive:(UIApplication *)application { 46 | // 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. 47 | } 48 | 49 | 50 | - (void)applicationWillTerminate:(UIApplication *)application { 51 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 52 | } 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MXRotationManager/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /MXRotationManager/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MXRotationManager/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MXRotationManager/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 29 | 37 | 44 | 52 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /MXRotationManager/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /MXRotationManager/MXRotationManager/MXRotationManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // MXRotationManager.h 3 | // Yunlu 4 | // 5 | // Created by Michael on 2018/9/21. 6 | // Copyright © 2018 DCloud. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MXRotationManager : NSObject 12 | 13 | @property (nonatomic, readonly) UIInterfaceOrientationMask interfaceOrientationMask; 14 | @property (nonatomic) UIDeviceOrientation orientation; 15 | 16 | + (instancetype)defaultManager; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MXRotationManager/MXRotationManager/MXRotationManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // MXRotationManager.m 3 | // Yunlu 4 | // 5 | // Created by Michael on 2018/9/21. 6 | // Copyright © 2018 DCloud. All rights reserved. 7 | // 8 | 9 | #import "MXRotationManager.h" 10 | #import 11 | 12 | static MXRotationManager *INSTANCE = nil; 13 | 14 | @interface MXRotationManager () 15 | 16 | @property (nonatomic, readwrite) UIInterfaceOrientationMask interfaceOrientationMask; 17 | 18 | @end 19 | 20 | @implementation MXRotationManager 21 | 22 | #pragma mark - singleton 23 | + (instancetype)defaultManager { 24 | 25 | static dispatch_once_t onceToken; 26 | dispatch_once(&onceToken, ^{ 27 | INSTANCE = [[super allocWithZone:nil] init]; 28 | INSTANCE.interfaceOrientationMask = UIInterfaceOrientationMaskPortrait; 29 | }); 30 | return INSTANCE; 31 | } 32 | 33 | + (instancetype)allocWithZone:(struct _NSZone *)zone { 34 | return [self defaultManager]; 35 | } 36 | 37 | + (id)copyWithZone:(NSZone *)zone { 38 | return [self defaultManager]; 39 | } 40 | 41 | + (id)mutableCopyWithZone:(NSZone *)zone { 42 | return [self defaultManager]; 43 | } 44 | 45 | #pragma mark - setter methods 46 | - (void)setOrientation:(UIDeviceOrientation)orientation { 47 | if (_orientation == orientation) return; 48 | if ([UIDevice currentDevice].orientation == orientation) { 49 | //强制旋转成与之前不一样的 50 | [[UIDevice currentDevice] setValue:@(_orientation) forKey:@"orientation"]; 51 | } 52 | _orientation = orientation; 53 | UIInterfaceOrientationMask interfaceOrientationMask = UIInterfaceOrientationMaskPortrait; 54 | switch (orientation) { 55 | case UIDeviceOrientationPortrait: 56 | interfaceOrientationMask = UIInterfaceOrientationMaskPortrait; 57 | break; 58 | case UIDeviceOrientationPortraitUpsideDown: 59 | interfaceOrientationMask = UIInterfaceOrientationMaskPortraitUpsideDown; 60 | break; 61 | case UIDeviceOrientationLandscapeRight: 62 | interfaceOrientationMask = UIInterfaceOrientationMaskLandscapeLeft; 63 | break; 64 | case UIDeviceOrientationLandscapeLeft: 65 | interfaceOrientationMask = UIInterfaceOrientationMaskLandscapeRight; 66 | break; 67 | default: 68 | interfaceOrientationMask = UIInterfaceOrientationMaskPortrait; 69 | break; 70 | } 71 | [MXRotationManager defaultManager].interfaceOrientationMask = interfaceOrientationMask; 72 | //强制旋转成全屏 73 | [[UIDevice currentDevice] setValue:@(orientation) forKey:@"orientation"]; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /MXRotationManager/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MXRotationManager 4 | // 5 | // Created by Michael on 2018/11/27. 6 | // Copyright © 2018 Michael. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /MXRotationManager/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MXRotationManager 4 | // 5 | // Created by Michael on 2018/11/27. 6 | // Copyright © 2018 Michael. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "MXRotationManager.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | } 21 | 22 | - (IBAction)changeOrientationBtnClicked:(UIButton *)sender { 23 | NSDictionary *dict = @{@"UIDeviceOrientationPortrait": @(UIDeviceOrientationPortrait), @"UIDeviceOrientationLandscapeLeft": @(UIDeviceOrientationLandscapeLeft), @"UIDeviceOrientationLandscapeRight": @(UIDeviceOrientationLandscapeRight)}; 24 | [MXRotationManager defaultManager].orientation = [dict[sender.currentTitle] unsignedIntegerValue]; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /MXRotationManager/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MXRotationManager 4 | // 5 | // Created by Michael on 2018/11/27. 6 | // Copyright © 2018 Michael. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MXRotationManager 2 | 3 | `MXRotationManager` has only one line code to help you change device orientation! 4 | 5 | ## Screenshots 6 | 7 | UIDeviceOrientationLandscapeLeft | UIDeviceOrientationLandscapeRight | 8 | ---|----| 9 | || 10 | 11 | 12 | 13 | ## How To Use 14 | 15 | implementation delegate method below in `AppDelegate.m` 16 | ``` 17 | - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 18 | return [MXRotationManager defaultManager].interfaceOrientationMask; 19 | } 20 | ``` 21 | 22 | ### UIDeviceOrientationLandscapeLeft 23 | 24 | ``` Objective-C 25 | [MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeLeft; 26 | ``` 27 | 28 | ### UIDeviceOrientationLandscapeRight 29 | 30 | ``` Objective-C 31 | [MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeRight; 32 | ``` 33 | 34 |
35 | 36 | ## 中文介绍 37 | 38 | `MXRotationManager` 一行代码控制设备旋转方向 39 | 40 | ## 屏幕截图 41 | 42 | UIDeviceOrientationLandscapeLeft | UIDeviceOrientationLandscapeRight | 43 | ---|----| 44 | || 45 | 46 | 47 | ## 如何使用 48 | 49 | 在 `AppDelegate.m`里 实现 `AppDelegate` 代理方法 50 | ``` 51 | - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 52 | return [MXRotationManager defaultManager].interfaceOrientationMask; 53 | } 54 | ``` 55 | 56 | ### UIDeviceOrientationLandscapeLeft 57 | 58 | ``` Objective-C 59 | [MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeLeft; 60 | ``` 61 | ### UIDeviceOrientationLandscapeRight 62 | 63 | ``` Objective-C 64 | [MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeRight; 65 | 66 | --------------------------------------------------------------------------------