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

ios开发点滴

2013年06月26日 ⁄ 综合 ⁄ 共 912字 ⁄ 字号 评论关闭

6.0带来的新特性;

首先4.3与4.5的不同之处在于 xcode4.5不再支持armv6即:iOS4.3.3以下的系统.不被支持的硬件设备包括:iPod 2nd gen, iPhone 3G 或更老的iPhone,也就是说如果是iOS4.3以下的手机,那么就不要想着用xcode4.5开发了;

其次在xcode4.5中,关于旋转回调的方法也有了改变,以前4.3中的旋转回调使用的是

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

{

return UIInterfaceOrientationIsPortrait(UIInterfaceOrientationPortrait);

}

在4.5中该回调已经不起作用了,使用如下方法进行替代

- (BOOL)shouldAutorotate

{

return YES;

}

- (NSUInteger)supportedInterfaceOrientations

{

return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortrait;

}

第一个方法就不用说明了,第二个方法需要注意的一点是return返回的值必须已经在项目plist文件中的Support interface orientations中已经指定,否则会出现编译错误;

题外话:我之前用4.3创建的项目,之后用4.5开发,但是使用这两个旋转回调并没有达到我想要的效果,我想只允许竖屏显示,但不论如何设置,viewController都是可旋转的,令人很头疼。

此外,iOS6.0中还新增了 autolayout ,也就是自动布局,此功能只有在iOS6.0的机器上才能使用,如果版本低于6.0,程序启动之后则会出现如下错误信息

‘Could not instantiate class named NSLayoutConstraint’

解决办法是:如果手机的sdk版本低于6.0 ,则需要将 inspector 中的 use autolayout的选框取消即可!

抱歉!评论已关闭.