现在的位置: 首页 > 综合 > 正文

xcode4.5.1、iphone5、ios6 使用记录

2018年05月25日 ⁄ 综合 ⁄ 共 2707字 ⁄ 字号 评论关闭

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);                      }                    }]; } 
【上篇】
【下篇】

抱歉!评论已关闭.