Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 在iOS 8.3中,仅为某些设备启用横向定向的正确方法_Objective C_Uiapplicationdelegate_Uiapplication_Size Classes_Ios8.3 - Fatal编程技术网

Objective c 在iOS 8.3中,仅为某些设备启用横向定向的正确方法

Objective c 在iOS 8.3中,仅为某些设备启用横向定向的正确方法,objective-c,uiapplicationdelegate,uiapplication,size-classes,ios8.3,Objective C,Uiapplicationdelegate,Uiapplication,Size Classes,Ios8.3,我正在iOS SDK 8.3中开发一个通用应用程序,并使用UISplitViewController。出于某些原因,我只想为iPad和iPhone 6 Plus启用横向定向 我找不到一个合适的方法来获得这个结果,目前我正在使用这个“糟糕”的替代函数 是否有一种优雅且“安全”的方法来获得相同的结果 在部署信息中启用横向设备定位。然后将这些宏作为参考: #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) #

我正在iOS SDK 8.3中开发一个通用应用程序,并使用UISplitViewController。出于某些原因,我只想为iPad和iPhone 6 Plus启用横向定向

我找不到一个合适的方法来获得这个结果,目前我正在使用这个“糟糕”的替代函数


是否有一种优雅且“安全”的方法来获得相同的结果

在部署信息中启用横向设备定位。然后将这些宏作为参考:

 #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
 #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
 #define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)

 #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
 #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
 #define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
 #define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))

 #define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
 #define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
 #define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
 #define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)

这与我的解决方案完全相同!还有别的办法吗?
 #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
 #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
 #define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)

 #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
 #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
 #define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
 #define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))

 #define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
 #define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
 #define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
 #define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
- (BOOL) shouldAutorotate {
BOOL shouldRotate = (IS_IPAD || IS_IPHONE_6P) ? YES : NO;
return shouldRotate;
}

- (NSUInteger) supportedInterfaceOrientations {
 NSUInteger orientation = (IS_IPAD || IS_IPHONE_6P) ? UIInterfaceOrientationMaskLandscape : UIInterfaceOrientationMaskPortrait;
 return orientation;
 }

 - (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
 UIInterfaceOrientation interface = (IS_IPAD || IS_IPHONE_6P) ? (UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight) : UIInterfaceOrientationPortrait;
 return interface;
 }