iOS 6中需要哪些方法来处理方向?我用过的是吼叫,这够了吗?
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (UIInterfaceOrientationLandscapeLeft == interfaceOrientation || UIInterfaceOrientationLandscapeRight == interfaceOrientation) {
return YES;
} else {
return NO;
}
}
我想让应用程序在iOS5和iOS6中都能正常工作
答案 0 :(得分:0)
在上述所有步骤之前,请在Targets->Summary
...
答案 1 :(得分:0)
我只知道iOS5 ......一个小修改
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
}
答案 2 :(得分:0)
是的,这三个就足够了。也适用于ios6,将preferredInterfaceOrientationForPresentation
添加为
return (UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight)
以优先方向启动应用的方法。
答案 3 :(得分:0)
适用于iOS6
//Support all orientation
- (NSUInteger)application:(UIApplication*)application
supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
return UIInterfaceOrientationMaskAll;
}
现在您需要更改根视图控制器
// iOS6 support
// ---
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
在iOS6中已弃用,iOS5支持仍然需要。
// ---
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
答案 4 :(得分:0)
您只需在.m
文件
#define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 )
#define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )
然后您必须在.m
文件
#ifdef IOS_OLDER_THAN_6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (UIInterfaceOrientationIsLandscape(toInterfaceOrientation));
}
#endif
#ifdef IOS_NEWER_OR_EQUAL_TO_6
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
#endif