├── ChangeOrientation.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── harvey.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── harvey.xcuserdatad │ └── xcschemes │ ├── ChangeOrientation.xcscheme │ └── xcschememanagement.plist ├── ChangeOrientation ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── BaseNavigationController.h ├── BaseNavigationController.m ├── GuideViewController.h ├── GuideViewController.m ├── Info.plist ├── MainViewController.h ├── MainViewController.m ├── index.html ├── main.m └── performance.gif └── README.md /ChangeOrientation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B95C55F91D05352B00119E69 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B95C55F81D05352B00119E69 /* main.m */; }; 11 | B95C55FC1D05352B00119E69 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B95C55FB1D05352B00119E69 /* AppDelegate.m */; }; 12 | B95C56041D05352B00119E69 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B95C56031D05352B00119E69 /* Assets.xcassets */; }; 13 | B95C56071D05352B00119E69 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B95C56051D05352B00119E69 /* LaunchScreen.storyboard */; }; 14 | B95C56101D05357E00119E69 /* GuideViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B95C560F1D05357E00119E69 /* GuideViewController.m */; }; 15 | B95C56131D05366D00119E69 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B95C56121D05366D00119E69 /* MainViewController.m */; }; 16 | B95C56151D0536EB00119E69 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = B95C56141D0536EB00119E69 /* index.html */; }; 17 | B95C56181D05381100119E69 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = B95C56171D05381100119E69 /* BaseNavigationController.m */; }; 18 | B9F705E61D05A3DB007A55FB /* performance.gif in Resources */ = {isa = PBXBuildFile; fileRef = B9F705E51D05A3DB007A55FB /* performance.gif */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | B95C55F41D05352A00119E69 /* ChangeOrientation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChangeOrientation.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | B95C55F81D05352B00119E69 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 24 | B95C55FA1D05352B00119E69 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 25 | B95C55FB1D05352B00119E69 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 26 | B95C56031D05352B00119E69 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | B95C56061D05352B00119E69 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | B95C56081D05352B00119E69 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | B95C560E1D05357E00119E69 /* GuideViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GuideViewController.h; sourceTree = ""; }; 30 | B95C560F1D05357E00119E69 /* GuideViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GuideViewController.m; sourceTree = ""; }; 31 | B95C56111D05366D00119E69 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; 32 | B95C56121D05366D00119E69 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; 33 | B95C56141D0536EB00119E69 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = ""; }; 34 | B95C56161D05381100119E69 /* BaseNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = ""; }; 35 | B95C56171D05381100119E69 /* BaseNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = ""; }; 36 | B9F705E51D05A3DB007A55FB /* performance.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = performance.gif; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | B95C55F11D05352A00119E69 /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | B95C55EB1D05352A00119E69 = { 51 | isa = PBXGroup; 52 | children = ( 53 | B95C55F61D05352B00119E69 /* ChangeOrientation */, 54 | B95C55F51D05352A00119E69 /* Products */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | B95C55F51D05352A00119E69 /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | B95C55F41D05352A00119E69 /* ChangeOrientation.app */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | B95C55F61D05352B00119E69 /* ChangeOrientation */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | B95C55FA1D05352B00119E69 /* AppDelegate.h */, 70 | B95C55FB1D05352B00119E69 /* AppDelegate.m */, 71 | B95C560E1D05357E00119E69 /* GuideViewController.h */, 72 | B95C560F1D05357E00119E69 /* GuideViewController.m */, 73 | B95C56111D05366D00119E69 /* MainViewController.h */, 74 | B95C56121D05366D00119E69 /* MainViewController.m */, 75 | B95C56161D05381100119E69 /* BaseNavigationController.h */, 76 | B95C56171D05381100119E69 /* BaseNavigationController.m */, 77 | B95C56141D0536EB00119E69 /* index.html */, 78 | B9F705E51D05A3DB007A55FB /* performance.gif */, 79 | B95C56031D05352B00119E69 /* Assets.xcassets */, 80 | B95C56051D05352B00119E69 /* LaunchScreen.storyboard */, 81 | B95C56081D05352B00119E69 /* Info.plist */, 82 | B95C55F71D05352B00119E69 /* Supporting Files */, 83 | ); 84 | path = ChangeOrientation; 85 | sourceTree = ""; 86 | }; 87 | B95C55F71D05352B00119E69 /* Supporting Files */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | B95C55F81D05352B00119E69 /* main.m */, 91 | ); 92 | name = "Supporting Files"; 93 | sourceTree = ""; 94 | }; 95 | /* End PBXGroup section */ 96 | 97 | /* Begin PBXNativeTarget section */ 98 | B95C55F31D05352A00119E69 /* ChangeOrientation */ = { 99 | isa = PBXNativeTarget; 100 | buildConfigurationList = B95C560B1D05352B00119E69 /* Build configuration list for PBXNativeTarget "ChangeOrientation" */; 101 | buildPhases = ( 102 | B95C55F01D05352A00119E69 /* Sources */, 103 | B95C55F11D05352A00119E69 /* Frameworks */, 104 | B95C55F21D05352A00119E69 /* Resources */, 105 | ); 106 | buildRules = ( 107 | ); 108 | dependencies = ( 109 | ); 110 | name = ChangeOrientation; 111 | productName = ChangeOrientation; 112 | productReference = B95C55F41D05352A00119E69 /* ChangeOrientation.app */; 113 | productType = "com.apple.product-type.application"; 114 | }; 115 | /* End PBXNativeTarget section */ 116 | 117 | /* Begin PBXProject section */ 118 | B95C55EC1D05352A00119E69 /* Project object */ = { 119 | isa = PBXProject; 120 | attributes = { 121 | LastUpgradeCheck = 0730; 122 | ORGANIZATIONNAME = Haley; 123 | TargetAttributes = { 124 | B95C55F31D05352A00119E69 = { 125 | CreatedOnToolsVersion = 7.3; 126 | }; 127 | }; 128 | }; 129 | buildConfigurationList = B95C55EF1D05352A00119E69 /* Build configuration list for PBXProject "ChangeOrientation" */; 130 | compatibilityVersion = "Xcode 3.2"; 131 | developmentRegion = English; 132 | hasScannedForEncodings = 0; 133 | knownRegions = ( 134 | en, 135 | Base, 136 | ); 137 | mainGroup = B95C55EB1D05352A00119E69; 138 | productRefGroup = B95C55F51D05352A00119E69 /* Products */; 139 | projectDirPath = ""; 140 | projectRoot = ""; 141 | targets = ( 142 | B95C55F31D05352A00119E69 /* ChangeOrientation */, 143 | ); 144 | }; 145 | /* End PBXProject section */ 146 | 147 | /* Begin PBXResourcesBuildPhase section */ 148 | B95C55F21D05352A00119E69 /* Resources */ = { 149 | isa = PBXResourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | B95C56151D0536EB00119E69 /* index.html in Resources */, 153 | B9F705E61D05A3DB007A55FB /* performance.gif in Resources */, 154 | B95C56071D05352B00119E69 /* LaunchScreen.storyboard in Resources */, 155 | B95C56041D05352B00119E69 /* Assets.xcassets in Resources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXResourcesBuildPhase section */ 160 | 161 | /* Begin PBXSourcesBuildPhase section */ 162 | B95C55F01D05352A00119E69 /* Sources */ = { 163 | isa = PBXSourcesBuildPhase; 164 | buildActionMask = 2147483647; 165 | files = ( 166 | B95C55FC1D05352B00119E69 /* AppDelegate.m in Sources */, 167 | B95C55F91D05352B00119E69 /* main.m in Sources */, 168 | B95C56101D05357E00119E69 /* GuideViewController.m in Sources */, 169 | B95C56131D05366D00119E69 /* MainViewController.m in Sources */, 170 | B95C56181D05381100119E69 /* BaseNavigationController.m in Sources */, 171 | ); 172 | runOnlyForDeploymentPostprocessing = 0; 173 | }; 174 | /* End PBXSourcesBuildPhase section */ 175 | 176 | /* Begin PBXVariantGroup section */ 177 | B95C56051D05352B00119E69 /* LaunchScreen.storyboard */ = { 178 | isa = PBXVariantGroup; 179 | children = ( 180 | B95C56061D05352B00119E69 /* Base */, 181 | ); 182 | name = LaunchScreen.storyboard; 183 | sourceTree = ""; 184 | }; 185 | /* End PBXVariantGroup section */ 186 | 187 | /* Begin XCBuildConfiguration section */ 188 | B95C56091D05352B00119E69 /* Debug */ = { 189 | isa = XCBuildConfiguration; 190 | buildSettings = { 191 | ALWAYS_SEARCH_USER_PATHS = NO; 192 | CLANG_ANALYZER_NONNULL = YES; 193 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 194 | CLANG_CXX_LIBRARY = "libc++"; 195 | CLANG_ENABLE_MODULES = YES; 196 | CLANG_ENABLE_OBJC_ARC = YES; 197 | CLANG_WARN_BOOL_CONVERSION = YES; 198 | CLANG_WARN_CONSTANT_CONVERSION = YES; 199 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 200 | CLANG_WARN_EMPTY_BODY = YES; 201 | CLANG_WARN_ENUM_CONVERSION = YES; 202 | CLANG_WARN_INT_CONVERSION = YES; 203 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 204 | CLANG_WARN_UNREACHABLE_CODE = YES; 205 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 206 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 207 | COPY_PHASE_STRIP = NO; 208 | DEBUG_INFORMATION_FORMAT = dwarf; 209 | ENABLE_STRICT_OBJC_MSGSEND = YES; 210 | ENABLE_TESTABILITY = YES; 211 | GCC_C_LANGUAGE_STANDARD = gnu99; 212 | GCC_DYNAMIC_NO_PIC = NO; 213 | GCC_NO_COMMON_BLOCKS = YES; 214 | GCC_OPTIMIZATION_LEVEL = 0; 215 | GCC_PREPROCESSOR_DEFINITIONS = ( 216 | "DEBUG=1", 217 | "$(inherited)", 218 | ); 219 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 220 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 221 | GCC_WARN_UNDECLARED_SELECTOR = YES; 222 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 223 | GCC_WARN_UNUSED_FUNCTION = YES; 224 | GCC_WARN_UNUSED_VARIABLE = YES; 225 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 226 | MTL_ENABLE_DEBUG_INFO = YES; 227 | ONLY_ACTIVE_ARCH = YES; 228 | SDKROOT = iphoneos; 229 | }; 230 | name = Debug; 231 | }; 232 | B95C560A1D05352B00119E69 /* Release */ = { 233 | isa = XCBuildConfiguration; 234 | buildSettings = { 235 | ALWAYS_SEARCH_USER_PATHS = NO; 236 | CLANG_ANALYZER_NONNULL = YES; 237 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 238 | CLANG_CXX_LIBRARY = "libc++"; 239 | CLANG_ENABLE_MODULES = YES; 240 | CLANG_ENABLE_OBJC_ARC = YES; 241 | CLANG_WARN_BOOL_CONVERSION = YES; 242 | CLANG_WARN_CONSTANT_CONVERSION = YES; 243 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 244 | CLANG_WARN_EMPTY_BODY = YES; 245 | CLANG_WARN_ENUM_CONVERSION = YES; 246 | CLANG_WARN_INT_CONVERSION = YES; 247 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 248 | CLANG_WARN_UNREACHABLE_CODE = YES; 249 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 250 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 251 | COPY_PHASE_STRIP = NO; 252 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 253 | ENABLE_NS_ASSERTIONS = NO; 254 | ENABLE_STRICT_OBJC_MSGSEND = YES; 255 | GCC_C_LANGUAGE_STANDARD = gnu99; 256 | GCC_NO_COMMON_BLOCKS = YES; 257 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 258 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 259 | GCC_WARN_UNDECLARED_SELECTOR = YES; 260 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 261 | GCC_WARN_UNUSED_FUNCTION = YES; 262 | GCC_WARN_UNUSED_VARIABLE = YES; 263 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 264 | MTL_ENABLE_DEBUG_INFO = NO; 265 | SDKROOT = iphoneos; 266 | VALIDATE_PRODUCT = YES; 267 | }; 268 | name = Release; 269 | }; 270 | B95C560C1D05352B00119E69 /* Debug */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 274 | INFOPLIST_FILE = ChangeOrientation/Info.plist; 275 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 276 | PRODUCT_BUNDLE_IDENTIFIER = com.suneee.ChangeOrientation; 277 | PRODUCT_NAME = "$(TARGET_NAME)"; 278 | }; 279 | name = Debug; 280 | }; 281 | B95C560D1D05352B00119E69 /* Release */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 285 | INFOPLIST_FILE = ChangeOrientation/Info.plist; 286 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 287 | PRODUCT_BUNDLE_IDENTIFIER = com.suneee.ChangeOrientation; 288 | PRODUCT_NAME = "$(TARGET_NAME)"; 289 | }; 290 | name = Release; 291 | }; 292 | /* End XCBuildConfiguration section */ 293 | 294 | /* Begin XCConfigurationList section */ 295 | B95C55EF1D05352A00119E69 /* Build configuration list for PBXProject "ChangeOrientation" */ = { 296 | isa = XCConfigurationList; 297 | buildConfigurations = ( 298 | B95C56091D05352B00119E69 /* Debug */, 299 | B95C560A1D05352B00119E69 /* Release */, 300 | ); 301 | defaultConfigurationIsVisible = 0; 302 | defaultConfigurationName = Release; 303 | }; 304 | B95C560B1D05352B00119E69 /* Build configuration list for PBXNativeTarget "ChangeOrientation" */ = { 305 | isa = XCConfigurationList; 306 | buildConfigurations = ( 307 | B95C560C1D05352B00119E69 /* Debug */, 308 | B95C560D1D05352B00119E69 /* Release */, 309 | ); 310 | defaultConfigurationIsVisible = 0; 311 | defaultConfigurationName = Release; 312 | }; 313 | /* End XCConfigurationList section */ 314 | }; 315 | rootObject = B95C55EC1D05352A00119E69 /* Project object */; 316 | } 317 | -------------------------------------------------------------------------------- /ChangeOrientation.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ChangeOrientation.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xhellohaley/ChangeOrientation/5fd9506835a9da37318ba9b7c003bee6d82be8d3/ChangeOrientation.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ChangeOrientation.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/ChangeOrientation.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ChangeOrientation.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ChangeOrientation.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | B95C55F31D05352A00119E69 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ChangeOrientation/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ChangeOrientation 4 | // 5 | // Created by Harvey on 16/6/6. 6 | // Copyright © 2016年 Haley. 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 | -------------------------------------------------------------------------------- /ChangeOrientation/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ChangeOrientation 4 | // 5 | // Created by Harvey on 16/6/6. 6 | // Copyright © 2016年 Haley. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | #import "GuideViewController.h" 12 | 13 | @interface AppDelegate () 14 | 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 21 | // Override point for customization after application launch. 22 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 23 | self.window.backgroundColor = [UIColor whiteColor]; 24 | 25 | GuideViewController *guideVC = [[GuideViewController alloc] init]; 26 | self.window.rootViewController = guideVC; 27 | 28 | [self.window makeKeyAndVisible]; 29 | 30 | return YES; 31 | } 32 | 33 | - (void)applicationWillResignActive:(UIApplication *)application { 34 | // 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. 35 | // 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. 36 | } 37 | 38 | - (void)applicationDidEnterBackground:(UIApplication *)application { 39 | // 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. 40 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 41 | } 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application { 44 | // 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. 45 | } 46 | 47 | - (void)applicationDidBecomeActive:(UIApplication *)application { 48 | // 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. 49 | } 50 | 51 | - (void)applicationWillTerminate:(UIApplication *)application { 52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /ChangeOrientation/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 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ChangeOrientation/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 | -------------------------------------------------------------------------------- /ChangeOrientation/BaseNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseNavigationController.h 3 | // 横竖屏切换 4 | // 5 | // Created by Harvey on 16/5/19. 6 | // Copyright © 2016年 Halley. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BaseNavigationController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ChangeOrientation/BaseNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseNavigationController.m 3 | // 横竖屏切换 4 | // 5 | // Created by Harvey on 16/5/19. 6 | // Copyright © 2016年 Halley. All rights reserved. 7 | // 8 | 9 | #import "BaseNavigationController.h" 10 | 11 | @implementation BaseNavigationController 12 | 13 | #pragma mark - override method 14 | - (void)viewDidLoad 15 | { 16 | [super viewDidLoad]; 17 | 18 | [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 19 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil]; 20 | } 21 | 22 | - (BOOL)shouldAutorotate 23 | { 24 | return [self.topViewController shouldAutorotate]; 25 | } 26 | 27 | - (UIInterfaceOrientationMask)supportedInterfaceOrientations 28 | { 29 | return [self.topViewController supportedInterfaceOrientations]; 30 | } 31 | 32 | - (void)deviceOrientationDidChange 33 | { 34 | NSLog(@"NAV deviceOrientationDidChange:%ld",(long)[UIDevice currentDevice].orientation); 35 | if([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) { 36 | [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; 37 | [self orientationChange:NO]; 38 | //注意: UIDeviceOrientationLandscapeLeft 与 UIInterfaceOrientationLandscapeRight 39 | } else if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft) { 40 | [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight]; 41 | [self orientationChange:YES]; 42 | } 43 | } 44 | 45 | - (void)orientationChange:(BOOL)landscapeRight 46 | { 47 | CGFloat width = [UIScreen mainScreen].bounds.size.width; 48 | CGFloat height = [UIScreen mainScreen].bounds.size.height; 49 | if (landscapeRight) { 50 | [UIView animateWithDuration:0.2f animations:^{ 51 | self.view.transform = CGAffineTransformMakeRotation(M_PI_2); 52 | self.view.bounds = CGRectMake(0, 0, width, height); 53 | }]; 54 | } else { 55 | [UIView animateWithDuration:0.2f animations:^{ 56 | self.view.transform = CGAffineTransformMakeRotation(0); 57 | self.view.bounds = CGRectMake(0, 0, width, height); 58 | }]; 59 | } 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /ChangeOrientation/GuideViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // GuideViewController.h 3 | // ChangeOrientation 4 | // 5 | // Created by Harvey on 16/6/6. 6 | // Copyright © 2016年 Haley. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GuideViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ChangeOrientation/GuideViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // GuideViewController.m 3 | // ChangeOrientation 4 | // 5 | // Created by Harvey on 16/6/6. 6 | // Copyright © 2016年 Haley. All rights reserved. 7 | // 8 | 9 | #import "GuideViewController.h" 10 | #import "MainViewController.h" 11 | #import "BaseNavigationController.h" 12 | 13 | @interface GuideViewController () 14 | 15 | @end 16 | 17 | @implementation GuideViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view. 22 | 23 | // UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 20)]; 24 | // label.text = @"这是引导页"; 25 | // label.center = self.view.center; 26 | // [self.view addSubview:label]; 27 | self.view.backgroundColor = [UIColor orangeColor]; 28 | 29 | UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 200, 20)]; 30 | btn.backgroundColor = [UIColor lightGrayColor]; 31 | btn.center = self.view.center; 32 | [btn setTitle:@"这是引导页,进入主页" forState:UIControlStateNormal]; 33 | [btn addTarget:self action:@selector(enterMain) forControlEvents:UIControlEventTouchUpInside]; 34 | 35 | [self.view addSubview:btn]; 36 | } 37 | 38 | - (void)enterMain 39 | { 40 | MainViewController *mainVC = [[MainViewController alloc] init]; 41 | BaseNavigationController *baseNaVC = [[BaseNavigationController alloc] initWithRootViewController:mainVC]; 42 | [self presentViewController:baseNaVC animated:YES completion:nil]; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ChangeOrientation/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ChangeOrientation/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // ChangeOrientation 4 | // 5 | // Created by Harvey on 16/6/6. 6 | // Copyright © 2016年 Haley. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MainViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ChangeOrientation/MainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.m 3 | // ChangeOrientation 4 | // 5 | // Created by Harvey on 16/6/6. 6 | // Copyright © 2016年 Haley. All rights reserved. 7 | // 8 | 9 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 10 | #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 11 | 12 | #import "MainViewController.h" 13 | 14 | @interface MainViewController () 15 | 16 | @property (strong, nonatomic) UIWebView *webView; /**< webView */ 17 | 18 | @end 19 | 20 | @implementation MainViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view. 25 | self.title = @"主页"; 26 | 27 | self.webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; 28 | self.webView.delegate = self; 29 | [self.view addSubview:self.webView]; 30 | 31 | UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:@"竖屏" style:UIBarButtonItemStylePlain target:self action:@selector(leftAction)]; 32 | self.navigationItem.leftBarButtonItem = leftItem; 33 | 34 | UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"横屏" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction)]; 35 | self.navigationItem.rightBarButtonItem = rightItem; 36 | 37 | NSString *url = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; 38 | [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]]; 39 | } 40 | 41 | - (BOOL)shouldAutorotate 42 | { 43 | return NO; 44 | } 45 | 46 | - (void)leftAction 47 | { 48 | [self interfaceOrientation:UIInterfaceOrientationPortrait]; 49 | } 50 | 51 | - (void)rightAction 52 | { 53 | [self interfaceOrientation:UIInterfaceOrientationLandscapeRight]; 54 | } 55 | 56 | #pragma mark - UIWebViewDelegate 57 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 58 | { 59 | NSURL * url = [request URL]; 60 | if ([[url scheme] isEqualToString:@"share"]) { 61 | NSArray *params =[url.query componentsSeparatedByString:@"&"]; 62 | 63 | NSMutableDictionary *tempDic = [NSMutableDictionary dictionary]; 64 | for (NSString *paramStr in params) { 65 | NSArray *dicArray = [paramStr componentsSeparatedByString:@"="]; 66 | if (dicArray.count > 1) { 67 | NSString *decodeValue = [dicArray[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 68 | [tempDic setObject:decodeValue forKey:dicArray[0]]; 69 | } 70 | } 71 | NSLog(@"tempDict:%@",tempDic); 72 | return NO; 73 | } else if ([[url scheme] isEqualToString:@"portrait"]) { 74 | NSLog(@"currentThread:%@",[NSThread currentThread]); 75 | [self interfaceOrientation:UIInterfaceOrientationPortrait]; 76 | return NO; 77 | } else if ([[url scheme] isEqualToString:@"landscape"]) { 78 | [self interfaceOrientation:UIInterfaceOrientationLandscapeRight]; 79 | return NO; 80 | } 81 | 82 | return YES; 83 | } 84 | 85 | - (void)interfaceOrientation:(UIInterfaceOrientation)orientation 86 | { 87 | if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { 88 | SEL selector = NSSelectorFromString(@"setOrientation:"); 89 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; 90 | [invocation setSelector:selector]; 91 | [invocation setTarget:[UIDevice currentDevice]]; 92 | int val = orientation; 93 | // 从2开始是因为0 1 两个参数已经被selector和target占用 94 | [invocation setArgument:&val atIndex:2]; 95 | [invocation invoke]; 96 | } 97 | } 98 | 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /ChangeOrientation/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 33 |
34 | 35 | 36 |
37 |
38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /ChangeOrientation/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ChangeOrientation 4 | // 5 | // Created by Harvey on 16/6/6. 6 | // Copyright © 2016年 Haley. 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 | -------------------------------------------------------------------------------- /ChangeOrientation/performance.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xhellohaley/ChangeOrientation/5fd9506835a9da37318ba9b7c003bee6d82be8d3/ChangeOrientation/performance.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ChangeOrientation 2 | 横竖屏切换的示例 3 | 这是用JS调用原生和原生调用的效果图 4 | 5 | ![效果图](https://github.com/Haley-Wong/ChangeOrientation/blob/master/ChangeOrientation/performance.gif) 6 | --------------------------------------------------------------------------------