我想在ios(ios 5和ios 6)中仅以横向方向进行我的应用 [英] I want to make my appliaction only in landscape orientation in ios (Both ios 5 and ios 6)

查看:123
本文介绍了我想在ios(ios 5和ios 6)中仅以横向方向进行我的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Xcode 4.5.1并使用此条件

I have use the Xcode 4.5.1 and use this conditions

#define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 )
#define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )


#ifdef IOS_OLDER_THAN_6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
    [image_signature setImage:[self resizeImage:image_signature.image]];
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
#endif
#ifdef IOS_NEWER_OR_EQUAL_TO_6
-(BOOL)shouldAutorotate {
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
    [image_signature setImage:[self resizeImage:image_signature.image]];
    return UIInterfaceOrientationMaskLandscapeLeft;
}
#endif

我在info.plist中添加了密钥。

I have add the key in info.plist.

<key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationLandscapeRight</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
    </array>

并设置支持界面方向

如果我已经在info.plist中添加了密钥并设置了支持方向而没有使用下面的代码,则应用程序无法在ios 5.0中运行

IF i have add the key in info.plist and set the support orientation and no use the below code , application is not work in ios 5.0

此代码可以工作但是我想要使用小替代概念....请帮助我..

This code is work but i want to use small alternative concept....Please help me..

提前致谢!!

推荐答案

你的方法不健康。只有#ifdef语句为真时才会编译预处理程序块。您所做的是使预处理器语句依赖于运行时参数。

Your approach is not healthy. The preprocessor blocks will only get compiled if #ifdef statements are true. What you have done is to make the preprocessor statements depend on runtime parameters.

您可以尝试删除所有预处理器块。使部署目标为5.0。

You can try removing all preprocessor blocks. Make your deployment target 5.0.

编辑:仅供参考,这些方法是回调方法,因此如果需要,系统会调用它们。 iOS5将调用shouldAutorotateToInterfaceOrientation方法同样iOS6将相应调用supportedInterfaceOrientations和iOS6的旋转方法。因此,您应该在运行时处理所有系统差异,而不是编译时,除非您是故意为两个不同的系统编译两个不同版本的应用程序。

FYI, these methods are callback methods so they will get called by system if needed. iOS5 will call shouldAutorotateToInterfaceOrientation method likewise iOS6 will call supportedInterfaceOrientations and iOS6's rotation methods accordingly. So you should handle all your system differences on runtime, not compile-time, unless you are compiling two different versions of app for two different systems on purpose.

这篇关于我想在ios(ios 5和ios 6)中仅以横向方向进行我的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆