iOS 纵向和横向应用仅适用于 iPhone 6+/7+
iOS app in portrait & landscape only for iPhone 6+/7+
如何设置我的项目配置以允许我的应用在 iPhone 6+ 和 7+ 型号上同时以纵向和横向模式工作,而其他 iPhone 型号必须仅支持纵向?
use this third party lib for detecting the running device's model and screen size.
//AppDelegate.h
@property () BOOL restrictRotation;
//AppDelegate.m
导入“AppDelegate.h”
导入“SDVersion.h”
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Check for device model
if ([SDiOSVersion deviceVersion] == iPhone7Plus){
NSLog(@"You got the iPhone 7. Nice!");
restrictRotation=YES;
}
else if ([SDiOSVersion deviceVersion] == iPhone6SPlus){
NSLog(@"You got the iPhone 6S Plus. Awesome device!");
restrictRotation=YES;
}
return YES;
}
-(UIInterfaceOrientationMask )application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(self.restrictRotation)
{
return UIInterfaceOrientationMaskPortrait;
}
else
{
return UIInterfaceOrientationMaskAll;
}
}
如何设置我的项目配置以允许我的应用在 iPhone 6+ 和 7+ 型号上同时以纵向和横向模式工作,而其他 iPhone 型号必须仅支持纵向?
use this third party lib for detecting the running device's model and screen size.
//AppDelegate.h
@property () BOOL restrictRotation;
//AppDelegate.m
导入“AppDelegate.h”
导入“SDVersion.h”
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Check for device model
if ([SDiOSVersion deviceVersion] == iPhone7Plus){
NSLog(@"You got the iPhone 7. Nice!");
restrictRotation=YES;
}
else if ([SDiOSVersion deviceVersion] == iPhone6SPlus){
NSLog(@"You got the iPhone 6S Plus. Awesome device!");
restrictRotation=YES;
}
return YES;
}
-(UIInterfaceOrientationMask )application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(self.restrictRotation)
{
return UIInterfaceOrientationMaskPortrait;
}
else
{
return UIInterfaceOrientationMaskAll;
}
}