├── DeviceOrientation.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── tgw.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── tgw.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── DeviceOrientation.xcscheme │ └── xcschememanagement.plist ├── DeviceOrientation ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── DeviceOrientation.h ├── DeviceOrientation.m ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── DeviceOrientationTests ├── DeviceOrientationTests.m └── Info.plist ├── DeviceOrientationUITests ├── DeviceOrientationUITests.m └── Info.plist └── README.md /DeviceOrientation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8B6AF6391E5D1931001C471C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B6AF6381E5D1931001C471C /* main.m */; }; 11 | 8B6AF63C1E5D1931001C471C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B6AF63B1E5D1931001C471C /* AppDelegate.m */; }; 12 | 8B6AF63F1E5D1931001C471C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B6AF63E1E5D1931001C471C /* ViewController.m */; }; 13 | 8B6AF6421E5D1931001C471C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8B6AF6401E5D1931001C471C /* Main.storyboard */; }; 14 | 8B6AF6441E5D1931001C471C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8B6AF6431E5D1931001C471C /* Assets.xcassets */; }; 15 | 8B6AF6471E5D1931001C471C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8B6AF6451E5D1931001C471C /* LaunchScreen.storyboard */; }; 16 | 8B6AF6521E5D1931001C471C /* DeviceOrientationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B6AF6511E5D1931001C471C /* DeviceOrientationTests.m */; }; 17 | 8B6AF65D1E5D1931001C471C /* DeviceOrientationUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B6AF65C1E5D1931001C471C /* DeviceOrientationUITests.m */; }; 18 | 8B6AF66C1E5D1A9F001C471C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B6AF66B1E5D1A9F001C471C /* CoreMotion.framework */; }; 19 | 8B6AF66F1E5D2882001C471C /* DeviceOrientation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B6AF66E1E5D2882001C471C /* DeviceOrientation.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 8B6AF64E1E5D1931001C471C /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 8B6AF62C1E5D1931001C471C /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 8B6AF6331E5D1931001C471C; 28 | remoteInfo = DeviceOrientation; 29 | }; 30 | 8B6AF6591E5D1931001C471C /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 8B6AF62C1E5D1931001C471C /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 8B6AF6331E5D1931001C471C; 35 | remoteInfo = DeviceOrientation; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 8B6AF6341E5D1931001C471C /* DeviceOrientation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DeviceOrientation.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 8B6AF6381E5D1931001C471C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 42 | 8B6AF63A1E5D1931001C471C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 43 | 8B6AF63B1E5D1931001C471C /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 44 | 8B6AF63D1E5D1931001C471C /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 45 | 8B6AF63E1E5D1931001C471C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 46 | 8B6AF6411E5D1931001C471C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 47 | 8B6AF6431E5D1931001C471C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 48 | 8B6AF6461E5D1931001C471C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 49 | 8B6AF6481E5D1931001C471C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | 8B6AF64D1E5D1931001C471C /* DeviceOrientationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DeviceOrientationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 8B6AF6511E5D1931001C471C /* DeviceOrientationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DeviceOrientationTests.m; sourceTree = ""; }; 52 | 8B6AF6531E5D1931001C471C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | 8B6AF6581E5D1931001C471C /* DeviceOrientationUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DeviceOrientationUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 8B6AF65C1E5D1931001C471C /* DeviceOrientationUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DeviceOrientationUITests.m; sourceTree = ""; }; 55 | 8B6AF65E1E5D1931001C471C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 8B6AF66B1E5D1A9F001C471C /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; }; 57 | 8B6AF66D1E5D2882001C471C /* DeviceOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientation.h; sourceTree = ""; }; 58 | 8B6AF66E1E5D2882001C471C /* DeviceOrientation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeviceOrientation.m; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 8B6AF6311E5D1931001C471C /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | 8B6AF66C1E5D1A9F001C471C /* CoreMotion.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | 8B6AF64A1E5D1931001C471C /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | 8B6AF6551E5D1931001C471C /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | /* End PBXFrameworksBuildPhase section */ 85 | 86 | /* Begin PBXGroup section */ 87 | 8B6AF62B1E5D1931001C471C = { 88 | isa = PBXGroup; 89 | children = ( 90 | 8B6AF6361E5D1931001C471C /* DeviceOrientation */, 91 | 8B6AF6501E5D1931001C471C /* DeviceOrientationTests */, 92 | 8B6AF65B1E5D1931001C471C /* DeviceOrientationUITests */, 93 | 8B6AF6351E5D1931001C471C /* Products */, 94 | 8B6AF66A1E5D1A9F001C471C /* Frameworks */, 95 | ); 96 | sourceTree = ""; 97 | }; 98 | 8B6AF6351E5D1931001C471C /* Products */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 8B6AF6341E5D1931001C471C /* DeviceOrientation.app */, 102 | 8B6AF64D1E5D1931001C471C /* DeviceOrientationTests.xctest */, 103 | 8B6AF6581E5D1931001C471C /* DeviceOrientationUITests.xctest */, 104 | ); 105 | name = Products; 106 | sourceTree = ""; 107 | }; 108 | 8B6AF6361E5D1931001C471C /* DeviceOrientation */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 8B6AF63A1E5D1931001C471C /* AppDelegate.h */, 112 | 8B6AF63B1E5D1931001C471C /* AppDelegate.m */, 113 | 8B6AF63D1E5D1931001C471C /* ViewController.h */, 114 | 8B6AF63E1E5D1931001C471C /* ViewController.m */, 115 | 8B6AF66D1E5D2882001C471C /* DeviceOrientation.h */, 116 | 8B6AF66E1E5D2882001C471C /* DeviceOrientation.m */, 117 | 8B6AF6401E5D1931001C471C /* Main.storyboard */, 118 | 8B6AF6431E5D1931001C471C /* Assets.xcassets */, 119 | 8B6AF6451E5D1931001C471C /* LaunchScreen.storyboard */, 120 | 8B6AF6481E5D1931001C471C /* Info.plist */, 121 | 8B6AF6371E5D1931001C471C /* Supporting Files */, 122 | ); 123 | path = DeviceOrientation; 124 | sourceTree = ""; 125 | }; 126 | 8B6AF6371E5D1931001C471C /* Supporting Files */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 8B6AF6381E5D1931001C471C /* main.m */, 130 | ); 131 | name = "Supporting Files"; 132 | sourceTree = ""; 133 | }; 134 | 8B6AF6501E5D1931001C471C /* DeviceOrientationTests */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 8B6AF6511E5D1931001C471C /* DeviceOrientationTests.m */, 138 | 8B6AF6531E5D1931001C471C /* Info.plist */, 139 | ); 140 | path = DeviceOrientationTests; 141 | sourceTree = ""; 142 | }; 143 | 8B6AF65B1E5D1931001C471C /* DeviceOrientationUITests */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 8B6AF65C1E5D1931001C471C /* DeviceOrientationUITests.m */, 147 | 8B6AF65E1E5D1931001C471C /* Info.plist */, 148 | ); 149 | path = DeviceOrientationUITests; 150 | sourceTree = ""; 151 | }; 152 | 8B6AF66A1E5D1A9F001C471C /* Frameworks */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | 8B6AF66B1E5D1A9F001C471C /* CoreMotion.framework */, 156 | ); 157 | name = Frameworks; 158 | sourceTree = ""; 159 | }; 160 | /* End PBXGroup section */ 161 | 162 | /* Begin PBXNativeTarget section */ 163 | 8B6AF6331E5D1931001C471C /* DeviceOrientation */ = { 164 | isa = PBXNativeTarget; 165 | buildConfigurationList = 8B6AF6611E5D1931001C471C /* Build configuration list for PBXNativeTarget "DeviceOrientation" */; 166 | buildPhases = ( 167 | 8B6AF6301E5D1931001C471C /* Sources */, 168 | 8B6AF6311E5D1931001C471C /* Frameworks */, 169 | 8B6AF6321E5D1931001C471C /* Resources */, 170 | ); 171 | buildRules = ( 172 | ); 173 | dependencies = ( 174 | ); 175 | name = DeviceOrientation; 176 | productName = DeviceOrientation; 177 | productReference = 8B6AF6341E5D1931001C471C /* DeviceOrientation.app */; 178 | productType = "com.apple.product-type.application"; 179 | }; 180 | 8B6AF64C1E5D1931001C471C /* DeviceOrientationTests */ = { 181 | isa = PBXNativeTarget; 182 | buildConfigurationList = 8B6AF6641E5D1931001C471C /* Build configuration list for PBXNativeTarget "DeviceOrientationTests" */; 183 | buildPhases = ( 184 | 8B6AF6491E5D1931001C471C /* Sources */, 185 | 8B6AF64A1E5D1931001C471C /* Frameworks */, 186 | 8B6AF64B1E5D1931001C471C /* Resources */, 187 | ); 188 | buildRules = ( 189 | ); 190 | dependencies = ( 191 | 8B6AF64F1E5D1931001C471C /* PBXTargetDependency */, 192 | ); 193 | name = DeviceOrientationTests; 194 | productName = DeviceOrientationTests; 195 | productReference = 8B6AF64D1E5D1931001C471C /* DeviceOrientationTests.xctest */; 196 | productType = "com.apple.product-type.bundle.unit-test"; 197 | }; 198 | 8B6AF6571E5D1931001C471C /* DeviceOrientationUITests */ = { 199 | isa = PBXNativeTarget; 200 | buildConfigurationList = 8B6AF6671E5D1931001C471C /* Build configuration list for PBXNativeTarget "DeviceOrientationUITests" */; 201 | buildPhases = ( 202 | 8B6AF6541E5D1931001C471C /* Sources */, 203 | 8B6AF6551E5D1931001C471C /* Frameworks */, 204 | 8B6AF6561E5D1931001C471C /* Resources */, 205 | ); 206 | buildRules = ( 207 | ); 208 | dependencies = ( 209 | 8B6AF65A1E5D1931001C471C /* PBXTargetDependency */, 210 | ); 211 | name = DeviceOrientationUITests; 212 | productName = DeviceOrientationUITests; 213 | productReference = 8B6AF6581E5D1931001C471C /* DeviceOrientationUITests.xctest */; 214 | productType = "com.apple.product-type.bundle.ui-testing"; 215 | }; 216 | /* End PBXNativeTarget section */ 217 | 218 | /* Begin PBXProject section */ 219 | 8B6AF62C1E5D1931001C471C /* Project object */ = { 220 | isa = PBXProject; 221 | attributes = { 222 | LastUpgradeCheck = 0800; 223 | ORGANIZATIONNAME = oopsr; 224 | TargetAttributes = { 225 | 8B6AF6331E5D1931001C471C = { 226 | CreatedOnToolsVersion = 8.0; 227 | DevelopmentTeam = E7P9CREU6H; 228 | ProvisioningStyle = Automatic; 229 | }; 230 | 8B6AF64C1E5D1931001C471C = { 231 | CreatedOnToolsVersion = 8.0; 232 | DevelopmentTeam = E7P9CREU6H; 233 | ProvisioningStyle = Automatic; 234 | TestTargetID = 8B6AF6331E5D1931001C471C; 235 | }; 236 | 8B6AF6571E5D1931001C471C = { 237 | CreatedOnToolsVersion = 8.0; 238 | DevelopmentTeam = E7P9CREU6H; 239 | ProvisioningStyle = Automatic; 240 | TestTargetID = 8B6AF6331E5D1931001C471C; 241 | }; 242 | }; 243 | }; 244 | buildConfigurationList = 8B6AF62F1E5D1931001C471C /* Build configuration list for PBXProject "DeviceOrientation" */; 245 | compatibilityVersion = "Xcode 3.2"; 246 | developmentRegion = English; 247 | hasScannedForEncodings = 0; 248 | knownRegions = ( 249 | en, 250 | Base, 251 | ); 252 | mainGroup = 8B6AF62B1E5D1931001C471C; 253 | productRefGroup = 8B6AF6351E5D1931001C471C /* Products */; 254 | projectDirPath = ""; 255 | projectRoot = ""; 256 | targets = ( 257 | 8B6AF6331E5D1931001C471C /* DeviceOrientation */, 258 | 8B6AF64C1E5D1931001C471C /* DeviceOrientationTests */, 259 | 8B6AF6571E5D1931001C471C /* DeviceOrientationUITests */, 260 | ); 261 | }; 262 | /* End PBXProject section */ 263 | 264 | /* Begin PBXResourcesBuildPhase section */ 265 | 8B6AF6321E5D1931001C471C /* Resources */ = { 266 | isa = PBXResourcesBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | 8B6AF6471E5D1931001C471C /* LaunchScreen.storyboard in Resources */, 270 | 8B6AF6441E5D1931001C471C /* Assets.xcassets in Resources */, 271 | 8B6AF6421E5D1931001C471C /* Main.storyboard in Resources */, 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | 8B6AF64B1E5D1931001C471C /* Resources */ = { 276 | isa = PBXResourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | }; 282 | 8B6AF6561E5D1931001C471C /* Resources */ = { 283 | isa = PBXResourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | }; 289 | /* End PBXResourcesBuildPhase section */ 290 | 291 | /* Begin PBXSourcesBuildPhase section */ 292 | 8B6AF6301E5D1931001C471C /* Sources */ = { 293 | isa = PBXSourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | 8B6AF63F1E5D1931001C471C /* ViewController.m in Sources */, 297 | 8B6AF63C1E5D1931001C471C /* AppDelegate.m in Sources */, 298 | 8B6AF66F1E5D2882001C471C /* DeviceOrientation.m in Sources */, 299 | 8B6AF6391E5D1931001C471C /* main.m in Sources */, 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | 8B6AF6491E5D1931001C471C /* Sources */ = { 304 | isa = PBXSourcesBuildPhase; 305 | buildActionMask = 2147483647; 306 | files = ( 307 | 8B6AF6521E5D1931001C471C /* DeviceOrientationTests.m in Sources */, 308 | ); 309 | runOnlyForDeploymentPostprocessing = 0; 310 | }; 311 | 8B6AF6541E5D1931001C471C /* Sources */ = { 312 | isa = PBXSourcesBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | 8B6AF65D1E5D1931001C471C /* DeviceOrientationUITests.m in Sources */, 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | /* End PBXSourcesBuildPhase section */ 320 | 321 | /* Begin PBXTargetDependency section */ 322 | 8B6AF64F1E5D1931001C471C /* PBXTargetDependency */ = { 323 | isa = PBXTargetDependency; 324 | target = 8B6AF6331E5D1931001C471C /* DeviceOrientation */; 325 | targetProxy = 8B6AF64E1E5D1931001C471C /* PBXContainerItemProxy */; 326 | }; 327 | 8B6AF65A1E5D1931001C471C /* PBXTargetDependency */ = { 328 | isa = PBXTargetDependency; 329 | target = 8B6AF6331E5D1931001C471C /* DeviceOrientation */; 330 | targetProxy = 8B6AF6591E5D1931001C471C /* PBXContainerItemProxy */; 331 | }; 332 | /* End PBXTargetDependency section */ 333 | 334 | /* Begin PBXVariantGroup section */ 335 | 8B6AF6401E5D1931001C471C /* Main.storyboard */ = { 336 | isa = PBXVariantGroup; 337 | children = ( 338 | 8B6AF6411E5D1931001C471C /* Base */, 339 | ); 340 | name = Main.storyboard; 341 | sourceTree = ""; 342 | }; 343 | 8B6AF6451E5D1931001C471C /* LaunchScreen.storyboard */ = { 344 | isa = PBXVariantGroup; 345 | children = ( 346 | 8B6AF6461E5D1931001C471C /* Base */, 347 | ); 348 | name = LaunchScreen.storyboard; 349 | sourceTree = ""; 350 | }; 351 | /* End PBXVariantGroup section */ 352 | 353 | /* Begin XCBuildConfiguration section */ 354 | 8B6AF65F1E5D1931001C471C /* Debug */ = { 355 | isa = XCBuildConfiguration; 356 | buildSettings = { 357 | ALWAYS_SEARCH_USER_PATHS = NO; 358 | CLANG_ANALYZER_NONNULL = YES; 359 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 360 | CLANG_CXX_LIBRARY = "libc++"; 361 | CLANG_ENABLE_MODULES = YES; 362 | CLANG_ENABLE_OBJC_ARC = YES; 363 | CLANG_WARN_BOOL_CONVERSION = YES; 364 | CLANG_WARN_CONSTANT_CONVERSION = YES; 365 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 366 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 367 | CLANG_WARN_EMPTY_BODY = YES; 368 | CLANG_WARN_ENUM_CONVERSION = YES; 369 | CLANG_WARN_INFINITE_RECURSION = YES; 370 | CLANG_WARN_INT_CONVERSION = YES; 371 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 372 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 373 | CLANG_WARN_UNREACHABLE_CODE = YES; 374 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 375 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 376 | COPY_PHASE_STRIP = NO; 377 | DEBUG_INFORMATION_FORMAT = dwarf; 378 | ENABLE_STRICT_OBJC_MSGSEND = YES; 379 | ENABLE_TESTABILITY = YES; 380 | GCC_C_LANGUAGE_STANDARD = gnu99; 381 | GCC_DYNAMIC_NO_PIC = NO; 382 | GCC_NO_COMMON_BLOCKS = YES; 383 | GCC_OPTIMIZATION_LEVEL = 0; 384 | GCC_PREPROCESSOR_DEFINITIONS = ( 385 | "DEBUG=1", 386 | "$(inherited)", 387 | ); 388 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 389 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 390 | GCC_WARN_UNDECLARED_SELECTOR = YES; 391 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 392 | GCC_WARN_UNUSED_FUNCTION = YES; 393 | GCC_WARN_UNUSED_VARIABLE = YES; 394 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 395 | MTL_ENABLE_DEBUG_INFO = YES; 396 | ONLY_ACTIVE_ARCH = YES; 397 | SDKROOT = iphoneos; 398 | TARGETED_DEVICE_FAMILY = "1,2"; 399 | }; 400 | name = Debug; 401 | }; 402 | 8B6AF6601E5D1931001C471C /* Release */ = { 403 | isa = XCBuildConfiguration; 404 | buildSettings = { 405 | ALWAYS_SEARCH_USER_PATHS = NO; 406 | CLANG_ANALYZER_NONNULL = YES; 407 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 408 | CLANG_CXX_LIBRARY = "libc++"; 409 | CLANG_ENABLE_MODULES = YES; 410 | CLANG_ENABLE_OBJC_ARC = YES; 411 | CLANG_WARN_BOOL_CONVERSION = YES; 412 | CLANG_WARN_CONSTANT_CONVERSION = YES; 413 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 414 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 415 | CLANG_WARN_EMPTY_BODY = YES; 416 | CLANG_WARN_ENUM_CONVERSION = YES; 417 | CLANG_WARN_INFINITE_RECURSION = YES; 418 | CLANG_WARN_INT_CONVERSION = YES; 419 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 420 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 421 | CLANG_WARN_UNREACHABLE_CODE = YES; 422 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 423 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 424 | COPY_PHASE_STRIP = NO; 425 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 426 | ENABLE_NS_ASSERTIONS = NO; 427 | ENABLE_STRICT_OBJC_MSGSEND = YES; 428 | GCC_C_LANGUAGE_STANDARD = gnu99; 429 | GCC_NO_COMMON_BLOCKS = YES; 430 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 431 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 432 | GCC_WARN_UNDECLARED_SELECTOR = YES; 433 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 434 | GCC_WARN_UNUSED_FUNCTION = YES; 435 | GCC_WARN_UNUSED_VARIABLE = YES; 436 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 437 | MTL_ENABLE_DEBUG_INFO = NO; 438 | SDKROOT = iphoneos; 439 | TARGETED_DEVICE_FAMILY = "1,2"; 440 | VALIDATE_PRODUCT = YES; 441 | }; 442 | name = Release; 443 | }; 444 | 8B6AF6621E5D1931001C471C /* Debug */ = { 445 | isa = XCBuildConfiguration; 446 | buildSettings = { 447 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 448 | DEVELOPMENT_TEAM = E7P9CREU6H; 449 | INFOPLIST_FILE = DeviceOrientation/Info.plist; 450 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 451 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 452 | PRODUCT_BUNDLE_IDENTIFIER = www.szmichoi.com.DeviceOrientation; 453 | PRODUCT_NAME = "$(TARGET_NAME)"; 454 | }; 455 | name = Debug; 456 | }; 457 | 8B6AF6631E5D1931001C471C /* Release */ = { 458 | isa = XCBuildConfiguration; 459 | buildSettings = { 460 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 461 | DEVELOPMENT_TEAM = E7P9CREU6H; 462 | INFOPLIST_FILE = DeviceOrientation/Info.plist; 463 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 464 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 465 | PRODUCT_BUNDLE_IDENTIFIER = www.szmichoi.com.DeviceOrientation; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | }; 468 | name = Release; 469 | }; 470 | 8B6AF6651E5D1931001C471C /* Debug */ = { 471 | isa = XCBuildConfiguration; 472 | buildSettings = { 473 | BUNDLE_LOADER = "$(TEST_HOST)"; 474 | DEVELOPMENT_TEAM = E7P9CREU6H; 475 | INFOPLIST_FILE = DeviceOrientationTests/Info.plist; 476 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 477 | PRODUCT_BUNDLE_IDENTIFIER = www.szmichoi.com.DeviceOrientationTests; 478 | PRODUCT_NAME = "$(TARGET_NAME)"; 479 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DeviceOrientation.app/DeviceOrientation"; 480 | }; 481 | name = Debug; 482 | }; 483 | 8B6AF6661E5D1931001C471C /* Release */ = { 484 | isa = XCBuildConfiguration; 485 | buildSettings = { 486 | BUNDLE_LOADER = "$(TEST_HOST)"; 487 | DEVELOPMENT_TEAM = E7P9CREU6H; 488 | INFOPLIST_FILE = DeviceOrientationTests/Info.plist; 489 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 490 | PRODUCT_BUNDLE_IDENTIFIER = www.szmichoi.com.DeviceOrientationTests; 491 | PRODUCT_NAME = "$(TARGET_NAME)"; 492 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DeviceOrientation.app/DeviceOrientation"; 493 | }; 494 | name = Release; 495 | }; 496 | 8B6AF6681E5D1931001C471C /* Debug */ = { 497 | isa = XCBuildConfiguration; 498 | buildSettings = { 499 | DEVELOPMENT_TEAM = E7P9CREU6H; 500 | INFOPLIST_FILE = DeviceOrientationUITests/Info.plist; 501 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 502 | PRODUCT_BUNDLE_IDENTIFIER = www.szmichoi.com.DeviceOrientationUITests; 503 | PRODUCT_NAME = "$(TARGET_NAME)"; 504 | TEST_TARGET_NAME = DeviceOrientation; 505 | }; 506 | name = Debug; 507 | }; 508 | 8B6AF6691E5D1931001C471C /* Release */ = { 509 | isa = XCBuildConfiguration; 510 | buildSettings = { 511 | DEVELOPMENT_TEAM = E7P9CREU6H; 512 | INFOPLIST_FILE = DeviceOrientationUITests/Info.plist; 513 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 514 | PRODUCT_BUNDLE_IDENTIFIER = www.szmichoi.com.DeviceOrientationUITests; 515 | PRODUCT_NAME = "$(TARGET_NAME)"; 516 | TEST_TARGET_NAME = DeviceOrientation; 517 | }; 518 | name = Release; 519 | }; 520 | /* End XCBuildConfiguration section */ 521 | 522 | /* Begin XCConfigurationList section */ 523 | 8B6AF62F1E5D1931001C471C /* Build configuration list for PBXProject "DeviceOrientation" */ = { 524 | isa = XCConfigurationList; 525 | buildConfigurations = ( 526 | 8B6AF65F1E5D1931001C471C /* Debug */, 527 | 8B6AF6601E5D1931001C471C /* Release */, 528 | ); 529 | defaultConfigurationIsVisible = 0; 530 | defaultConfigurationName = Release; 531 | }; 532 | 8B6AF6611E5D1931001C471C /* Build configuration list for PBXNativeTarget "DeviceOrientation" */ = { 533 | isa = XCConfigurationList; 534 | buildConfigurations = ( 535 | 8B6AF6621E5D1931001C471C /* Debug */, 536 | 8B6AF6631E5D1931001C471C /* Release */, 537 | ); 538 | defaultConfigurationIsVisible = 0; 539 | }; 540 | 8B6AF6641E5D1931001C471C /* Build configuration list for PBXNativeTarget "DeviceOrientationTests" */ = { 541 | isa = XCConfigurationList; 542 | buildConfigurations = ( 543 | 8B6AF6651E5D1931001C471C /* Debug */, 544 | 8B6AF6661E5D1931001C471C /* Release */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | }; 548 | 8B6AF6671E5D1931001C471C /* Build configuration list for PBXNativeTarget "DeviceOrientationUITests" */ = { 549 | isa = XCConfigurationList; 550 | buildConfigurations = ( 551 | 8B6AF6681E5D1931001C471C /* Debug */, 552 | 8B6AF6691E5D1931001C471C /* Release */, 553 | ); 554 | defaultConfigurationIsVisible = 0; 555 | }; 556 | /* End XCConfigurationList section */ 557 | }; 558 | rootObject = 8B6AF62C1E5D1931001C471C /* Project object */; 559 | } 560 | -------------------------------------------------------------------------------- /DeviceOrientation.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DeviceOrientation.xcodeproj/project.xcworkspace/xcuserdata/tgw.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oopsr/DeviceOrientation/b1cfa8c31aa33fc9f9bdc386650ee7d374393b6d/DeviceOrientation.xcodeproj/project.xcworkspace/xcuserdata/tgw.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /DeviceOrientation.xcodeproj/xcuserdata/tgw.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /DeviceOrientation.xcodeproj/xcuserdata/tgw.xcuserdatad/xcschemes/DeviceOrientation.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /DeviceOrientation.xcodeproj/xcuserdata/tgw.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DeviceOrientation.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 8B6AF6331E5D1931001C471C 16 | 17 | primary 18 | 19 | 20 | 8B6AF64C1E5D1931001C471C 21 | 22 | primary 23 | 24 | 25 | 8B6AF6571E5D1931001C471C 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /DeviceOrientation/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DeviceOrientation 4 | // 5 | // Created by Tg W on 17/2/22. 6 | // Copyright © 2017年 oopsr. 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 | -------------------------------------------------------------------------------- /DeviceOrientation/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DeviceOrientation 4 | // 5 | // Created by Tg W on 17/2/22. 6 | // Copyright © 2017年 oopsr. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // 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. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /DeviceOrientation/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /DeviceOrientation/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 | 27 | 28 | -------------------------------------------------------------------------------- /DeviceOrientation/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 | 28 | 35 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /DeviceOrientation/DeviceOrientation.h: -------------------------------------------------------------------------------- 1 | // 2 | // DeviceOrientation.h 3 | // DeviceOrientation 4 | // 5 | // Created by Tg W on 17/2/22. 6 | // Copyright © 2017年 oopsr. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger,TgDirection) { 12 | TgDirectionUnkown, 13 | TgDirectionPortrait, 14 | TgDirectionDown, 15 | TgDirectionRight, 16 | TgDirectionleft, 17 | }; 18 | 19 | @protocol DeviceOrientationDelegate 20 | 21 | - (void)directionChange:(TgDirection)direction; 22 | 23 | @end 24 | @interface DeviceOrientation : NSObject 25 | 26 | @property(nonatomic,strong)iddelegate; 27 | 28 | - (instancetype)initWithDelegate:(id)delegate; 29 | /** 30 | 开启监听 31 | */ 32 | - (void)startMonitor; 33 | /** 34 | 结束监听,请stop 35 | */ 36 | - (void)stop; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /DeviceOrientation/DeviceOrientation.m: -------------------------------------------------------------------------------- 1 | // 2 | // DeviceOrientation.m 3 | // DeviceOrientation 4 | // 5 | // Created by Tg W on 17/2/22. 6 | // Copyright © 2017年 oopsr. All rights reserved. 7 | // 8 | 9 | #import "DeviceOrientation.h" 10 | #import 11 | 12 | @interface DeviceOrientation () { 13 | 14 | CMMotionManager *_motionManager; 15 | TgDirection _direction; 16 | 17 | } 18 | @end 19 | //sensitive 灵敏度 20 | static const float sensitive = 0.77; 21 | 22 | @implementation DeviceOrientation 23 | 24 | - (instancetype)initWithDelegate:(id)delegate { 25 | self = [super init]; 26 | if (self) { 27 | 28 | _delegate = delegate; 29 | } 30 | return self; 31 | } 32 | - (void)startMonitor { 33 | 34 | [self start]; 35 | } 36 | 37 | - (void)stop { 38 | 39 | [_motionManager stopDeviceMotionUpdates]; 40 | } 41 | 42 | 43 | //陀螺仪 每隔一个间隔做轮询 44 | - (void)start{ 45 | 46 | if (_motionManager == nil) { 47 | 48 | _motionManager = [[CMMotionManager alloc] init]; 49 | } 50 | _motionManager.deviceMotionUpdateInterval = 1/40.f; 51 | if (_motionManager.deviceMotionAvailable) { 52 | 53 | [_motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] 54 | withHandler: ^(CMDeviceMotion *motion, NSError *error){ 55 | [self performSelectorOnMainThread:@selector(deviceMotion:) withObject:motion waitUntilDone:YES]; 56 | }]; 57 | } 58 | } 59 | - (void)deviceMotion:(CMDeviceMotion *)motion{ 60 | 61 | double x = motion.gravity.x; 62 | double y = motion.gravity.y; 63 | if (y < 0 ) { 64 | if (fabs(y) > sensitive) { 65 | if (_direction != TgDirectionPortrait) { 66 | _direction = TgDirectionPortrait; 67 | if ([self.delegate respondsToSelector:@selector(directionChange:)]) { 68 | [self.delegate directionChange:_direction]; 69 | } 70 | } 71 | } 72 | }else { 73 | if (y > sensitive) { 74 | if (_direction != TgDirectionDown) { 75 | _direction = TgDirectionDown; 76 | if ([self.delegate respondsToSelector:@selector(directionChange:)]) { 77 | [self.delegate directionChange:_direction]; 78 | } 79 | } 80 | } 81 | } 82 | if (x < 0 ) { 83 | if (fabs(x) > sensitive) { 84 | if (_direction != TgDirectionleft) { 85 | _direction = TgDirectionleft; 86 | if ([self.delegate respondsToSelector:@selector(directionChange:)]) { 87 | [self.delegate directionChange:_direction]; 88 | } 89 | } 90 | } 91 | }else { 92 | if (x > sensitive) { 93 | if (_direction != TgDirectionRight) { 94 | _direction = TgDirectionRight; 95 | if ([self.delegate respondsToSelector:@selector(directionChange:)]) { 96 | [self.delegate directionChange:_direction]; 97 | } 98 | } 99 | } 100 | } 101 | } 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /DeviceOrientation/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | -------------------------------------------------------------------------------- /DeviceOrientation/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // DeviceOrientation 4 | // 5 | // Created by Tg W on 17/2/22. 6 | // Copyright © 2017年 oopsr. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property (weak, nonatomic) IBOutlet UILabel *loglabel; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /DeviceOrientation/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // DeviceOrientation 4 | // 5 | // Created by Tg W on 17/2/22. 6 | // Copyright © 2017年 oopsr. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DeviceOrientation.h" 11 | 12 | @interface ViewController () 13 | @end 14 | 15 | @implementation ViewController { 16 | DeviceOrientation *deviceMotion; 17 | } 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | deviceMotion = [[DeviceOrientation alloc]initWithDelegate:self]; 23 | } 24 | 25 | - (IBAction)startMonitor:(id)sender { 26 | 27 | [deviceMotion startMonitor]; 28 | } 29 | - (IBAction)stop:(id)sender { 30 | //不用时请关掉 31 | [deviceMotion stop]; 32 | 33 | self.loglabel.text = @""; 34 | } 35 | 36 | - (void)directionChange:(TgDirection)direction { 37 | 38 | switch (direction) { 39 | case TgDirectionPortrait: 40 | 41 | self.loglabel.text = @"protrait"; 42 | 43 | break; 44 | case TgDirectionDown: 45 | 46 | self.loglabel.text = @"down"; 47 | 48 | break; 49 | case TgDirectionRight: 50 | 51 | self.loglabel.text = @"right"; 52 | 53 | break; 54 | case TgDirectionleft: 55 | 56 | self.loglabel.text = @"left"; 57 | 58 | break; 59 | 60 | default: 61 | break; 62 | } 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /DeviceOrientation/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DeviceOrientation 4 | // 5 | // Created by Tg W on 17/2/22. 6 | // Copyright © 2017年 oopsr. 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 | -------------------------------------------------------------------------------- /DeviceOrientationTests/DeviceOrientationTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DeviceOrientationTests.m 3 | // DeviceOrientationTests 4 | // 5 | // Created by Tg W on 17/2/22. 6 | // Copyright © 2017年 oopsr. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DeviceOrientationTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation DeviceOrientationTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /DeviceOrientationTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /DeviceOrientationUITests/DeviceOrientationUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DeviceOrientationUITests.m 3 | // DeviceOrientationUITests 4 | // 5 | // Created by Tg W on 17/2/22. 6 | // Copyright © 2017年 oopsr. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DeviceOrientationUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation DeviceOrientationUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /DeviceOrientationUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DeviceOrientation 2 | iOS中关闭屏幕旋转功能时判断屏幕方向 3 | 4 | 利用螺旋仪运动模块实现 5 | 需引入CoreMotion.frameWork框架 6 | ![效果图](http://wx3.sinaimg.cn/mw690/c320c33egy1fcz3pb9g8lj20ku112mxs.jpg) 7 | --------------------------------------------------------------------------------