<iOS> xcode4.5.1、iphone5、ios6 兼容

1.修改工程名:直接选中工程名点一下,就像修改名称夹名称一样简单了。


2.导入旧工程解决xcode4.5以后模拟器屏幕不旋转的问题

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)

    self.window.rootViewController = navigationCtrl;

else

    [self.window addSubview:navigationCtrl.view];



3.支持iPhone5:添加Retina 4 launch image“Default-568h@2x.png”

图片尺寸:

 

  Default.png   320x480

     Default@2x.png  640x960

     Default-568h@2x.png  640x1136


4.Icon新增:Icon-72@2x.png,Icon-Small-50@2x.png;



5.判断是否为iphone5

 

CGFloat screenWidth = [[UIScreen mainScreenbounds].size.width;

        CGFloat screenHeight = [[UIScreen mainScreenbounds].size.height;

        if ((screenWidth==568)||(screenHeight==568)) {

            isiPhone5 = YES;

        }


6.iphone5宽高:320*568
CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
 CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;


7.打开iphone5模拟器:硬件-》设备-》iPhone(Retina 4-inch) 
4.xcode4.5不再支持armv6即:iOS4.3.3以下的系统.
不被支持的硬件设备包括:iPod 2nd gen, iPhone 3G 或更老的iPhone
例如我打包时的错误提示就是:
warning: iOS deployment targets lower than 4.3 are not supported (current IPHONEOS_DEPLOYMENT_TARGET = "4.0", ARCHS = "armv7"). (null):  iPhone/iPod Touch: application executable is missing a required architecture.  At least one of the following architecture(s) must be present: armv6 (-19033) 
因为喜欢用Block,所以我开发的东东,一般最低都支持iOS4.0,看来是苹果逼着开发者和用户升级啊。
5.奉上一段判断iPhone的代码
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) 
用时候直接
if (iPhone5) ooxx 
就可以了。
另外,如果代码写界面的话,在iPhone5下View的高是568哟~
6.关于xib自适应的问题
默认的话,如果你的界面上包含scrollview/TableView的话,这个界面基本上是不用改的,因为中间部分会自动拉伸。如果不包含这两个全屏的控件的话,怕是要自已再添加一个专门针对iPhone5的xib了。办法很简单,新建一个xib文件,将里面view的size设置成Retina 4 Full Screen就可以了。上面已经提到怎么判断iPhone5了,怎样读取不同的xib文件不用上代码了吧?
7.关于屏幕旋转(iOS5的时候就出过一次状况,这次又来)
要深入理解这个问题,还需要您自已亲自做一些实验,iOS6取消了一个api,增加了两个api,但是这一去一加满足不了我的情况:应用在所有的界面都是竖屏,只在一个屏幕是横屏。就这一个情况要实现费了我半天的功夫。只说一下我最后怎么实现的。
首先:这横屏的xib里面的view就是横的
其次:屏幕适应只支持横屏
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{   return UIInterfaceOrientationIsLandscape(interfaceOrientation); } 
第三:在这个view是present出来的
第四:viewDidLoad里隐藏状态栏
- (void)viewDidLoad{   if (IOSSystemVersion >= 5.0) {     //5.0及以后,不整这个,界面错位 整这个带动画的话,容易看到一个白头     [[UIApplication sharedApplication] setStatusBarHidden:YES];   } } 
第五:viewWillAppear自已将view旋转90度
- (void)viewWillAppear:(BOOL)animated{   [super viewWillAppear:animated];   [UIView animateWithDuration:0.0f                    animations:^{                      [self.view setTransform: CGAffineTransformMakeRotation(M_PI / 2)];                      if (iPhone5) {                        self.view.frame = CGRectMake(0, 0, 568, 320);                      }                      else{                        self.view.frame = CGRectMake(0, 0, 480, 320);                      }                    }]; } 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值