iOS 8 牛刀小试
iOS 8 牛刀小试
1、UIWindow的bounds发生变化(Window本身发生了旋转)
iOS 7之前Window的bounds不会随着方向而变化,但是到了iOS 8以后,随着设备方向的旋转,window.bounds.size.width和window.bounds.size.height也会相应发生变化。
做个很简单的测试,代码如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch. [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:nil]; return YES;
} - (void)orientationChanged:(NSNotification*)noti { UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
NSString *orientationDes = nil;
switch (orientation) {
case UIDeviceOrientationLandscapeLeft:
orientationDes = @"UIInterfaceOrientationLandscapeRight";
break;
case UIDeviceOrientationLandscapeRight:
orientationDes = @"UIInterfaceOrientationLandscapeLeft";
break;
case UIDeviceOrientationPortrait:
orientationDes = @"UIInterfaceOrientationPortrait";
break;
case UIDeviceOrientationPortraitUpsideDown:
orientationDes = @"UIInterfaceOrientationPortraitUpsideDown";
break;
default:
orientationDes = @"";
break;
} NSLog(@"system ver: %@, \rorientaion: %@, \rwindow bounds: %@",
[UIDevice currentDevice].systemVersion,
orientationDes,
NSStringFromCGRect(self.window.bounds));
}
示例代码很简单,新建一个工程,然后在delegate中直接添加以上代码即可。
iOS 8上运行结果为:
2014-06-04 09:26:32.016 SviOS8[4143:61114] system ver: 8.0,
orientaion: UIInterfaceOrientationLandscapeRight,
window bounds: {{0, 0}, {320, 480}}
2014-06-04 09:26:34.788 SviOS8[4143:61114] system ver: 8.0,
orientaion: UIInterfaceOrientationPortrait,
window bounds: {{0, 0}, {480, 320}}
2014-06-04 09:26:35.791 SviOS8[4143:61114] system ver: 8.0,
orientaion: UIInterfaceOrientationLandscapeLeft,
window bounds: {{0, 0}, {320, 480}}
2014-06-04 09:26:47.468 SviOS8[4143:61114] system ver: 8.0,
orientaion: UIInterfaceOrientationPortraitUpsideDown,
window bounds: {{0, 0}, {480, 320}}
iOS 7及之前的版本运行结果为:
2014-06-04 09:39:00.527 SviOS8[4380:70b] system ver: 7.0.3,
orientaion: UIInterfaceOrientationLandscapeRight,
window bounds: {{0, 0}, {320, 480}}
2014-06-04 09:39:00.895 SviOS8[4380:70b] system ver: 7.0.3,
orientaion: UIInterfaceOrientationPortrait,
window bounds: {{0, 0}, {320, 480}}
2014-06-04 09:39:01.225 SviOS8[4380:70b] system ver: 7.0.3,
orientaion: UIInterfaceOrientationLandscapeLeft,
window bounds: {{0, 0}, {320, 480}}
2014-06-04 09:39:11.004 SviOS8[4380:70b] system ver: 7.0.3,
orientaion: UIInterfaceOrientationPortraitUpsideDown,
window bounds: {{0, 0}, {320, 480}}
通过对比我们可以清晰的看到iOS 8中UIWindow在处理旋转时策略的变更,虽然会因为与之前的版本不同导致现有项目布局存在的bug,但是可以看到iOS 8中的处理方式更加符合我们的预期,在竖向的时候我们就获取到width < height, 在横向则是 width > height,这个符合所见即所得的原则。
题外话,不管是iOS 7还是之前的版本,以及最新出的iOS 8,所有的ViewController的bounds都是正确的,所以只需要坚持一个原则“所有布局都是基于VC.view.bounds布局,那么你的App的显示就一切正常。”
当然如果你有任何View不受VC的管理,直接添加到window上,那么就悲剧了,请添加代码去单独支持。
好消息:所有基于iOS 7 SDK编译的程序,window的机制还遵循原来的机制,也就是说可以平滑过度到iOS系统,所有界面布局一切正常。不得不说苹果这一点做的真赞,不愧是一家伟大的公司。
2、安装iOS 8 beta版本注意事项
官方给出的注意事项地址: http://adcdownload.apple.com//wwdc_2014/ios_8_beta_wg4j9a/ios_beta_software_installation_guide.pdf
主要意思是:
1)升级后不可降级,so升级之前还是想清楚
2)做好备份工作,因为毕竟是beta版本,可能有些不稳定的地方,可能在升级过程中会丢失数据
3)支持设备:
iPhone 4s, iPhone 5, iPhone 5c, iPhone 5s, iPod touch (5th gen),
iPad 2, iPad with Retina display, iPad Air and iPad mini
4)目前只支持开发者预览
5)反馈问题地址如下: https://developer.apple.com/bug-reporting/
3、QR Code支持
Core Image framework (CoreImage.framework
)新增了如下API:
支持自定义imageKernels
增加矩形检测和图片中二维码识别功能
详细文档: Core Image Reference Collection.
4、UITableView的Edit模式异常
iOS 8预览版中TableView进入edit模式以后,调用reloadData以后tableView中cell的编辑模式的样式显示会出现问题(编辑空间消失),不知道后面苹果的正式发布的iOS 8版本中会不会解决这个问题。
5、View Debugger
xCode6中新增加了UI调试神器View Debugger,该工具可以在调试中绘制出当前View层级的3D显示,如下图所示:
View debugging. Using the view debugger makes debugging an app’s appearance is as easy as debugging lines of code. A single button click pauses your running app and “explodes” the paused UI into a 3D rendering, separating each layer of a stack of views. Using the view debugger makes it immediately obvious why an image may be clipped and invisible, and the order of the graphical elements becomes clear. By selecting any view, you can inspect the details by jumping to the relevant code in the assistant editor source view. The view debugger also displays Auto Layout constraints, making it easy to see where conflicts cause problems.
官方文档中解释的很清楚,有了该工具以后遇到View被覆盖,超出父View等原因引起的无法响应用户事件的问题可以轻松解决了,真是开发者的一大福音。
注:本篇文章,持续更新,欢迎一起讨论iOS 8
如果觉得本文帮到了你,请推荐给身边的朋友
转载请著名出处,有什么问题欢迎留言
iOS 8 牛刀小试的更多相关文章
- 【原】webp图片牛刀小试
其实今年很早就有接触到webp图片的概念,只是一直没怎么弄.今天在一个小项目中小用了一番.总结总结 采用 what,why,how的方式来总结 what? 什么是webp图片? 维基百科: ...
- React-Native牛刀小试仿京东砍啊砍砍到你手软
React-Native牛刀小试仿京东砍啊砍砍到你手软 React-Native基础教程 *React-Native基础篇作者git *React-Native官方文档 *Demo 几个月前faceb ...
- iOS可视化动态绘制连通图
上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...
- 【疯狂造轮子-iOS】JSON转Model系列之二
[疯狂造轮子-iOS]JSON转Model系列之二 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇<[疯狂造轮子-iOS]JSON转Model系列之一> ...
- 【疯狂造轮子-iOS】JSON转Model系列之一
[疯狂造轮子-iOS]JSON转Model系列之一 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 之前一直看别人的源码,虽然对自己提升比较大,但毕竟不是自己写的,很容易遗 ...
- iOS总结_UI层自我复习总结
UI层复习笔记 在main文件中,UIApplicationMain函数一共做了三件事 根据第三个参数创建了一个应用程序对象 默认写nil,即创建的是UIApplication类型的对象,此对象看成是 ...
- iOS代码规范(OC和Swift)
下面说下iOS的代码规范问题,如果大家觉得还不错,可以直接用到项目中,有不同意见 可以在下面讨论下. 相信很多人工作中最烦的就是代码不规范,命名不规范,曾经见过一个VC里有3个按钮被命名为button ...
- JS调用Android、Ios原生控件
在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...
- 告别被拒,如何提升iOS审核通过率(上篇)
iOS审核一直是每款移动产品上架苹果商店时面对的一座大山,每次提审都像是一次漫长而又悲壮的旅行,经常被苹果拒之门外,无比煎熬.那么问题来了,我们有没有什么办法准确把握苹果审核准则,从而提升审核的通过率 ...
随机推荐
- 洛谷P2242 公路维修问题(Road)
题目描述 在一个夜黑风高,下着暴风雨的夜晚,farmer John的牛棚的屋顶.门被吹飞了. 好在许多牛正在度假,所以牛棚没有住满. 牛棚一个紧挨着另一个被排成一行,牛就住在里面过夜. 有些牛棚里有牛 ...
- 正则表达式——语法
正则表达式(regular expression)--描述一种字符串匹配模式,可以用来检测一个字符串是否包含特定的子串.用其他字符串将其代替.提取出某个符合要求的子串. 正则表达式 由普通字符 和 ...
- AngularJs ngApp、ngBind、ngBindHtml、ngNonBindable
ngApp 使用这个指令自动启动一个AngularJS应用.ngApp指令指定了应用程序的根节点,通常会将ngApp放置在网页的根节点如<body>或<html >标签的. 格 ...
- hdu 2036 - 改革春风吹满地(计算几何)
题意:求解多边形面积 解法: 先了解数学上"叉积"的含义与性质: 三角形ΔABC的面积为: 我们可以依次计算每个三角形的面积,ΔABC,ΔACE,ΔEF - - 所有三角形的面积之 ...
- centos6.5下安装mysql
http://www.centoscn.com/mysql/2014/0812/3481.html 1.使用yum命令安装mysql [root@bogon ~]# yum -y install m ...
- python 培训之HTTP
1. urllib #!/usr/env/python # -*- coding:UTF-8 -*- from __future__ import print_function import sys ...
- 谁都能看懂的单点登录(SSO)实现方式(附源码)
SSO的基本概念 SSO英文全称Single Sign On(单点登录).SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统.它包括可以将这次主要的登录映射到其他应用中用于同 ...
- dig的用法
Dig是linux中的域名解析工具,功能比nslookup强很多,使用也很方便,不用象nslookup总是set不停. Dig是domain information groper的缩写,知道了来源想必 ...
- 初识Hadoop一,配置及启动服务
一.Hadoop简介: Hadoop是由Apache基金会所开发的分布式系统基础架构,实现了一个分布式文件系统(Hadoop Distributed File System),简称HDFS:Hadoo ...
- [Redis]如何通过Powershell创建Redis服务
目前Redis在中国上线了,不过只是预览版而且不能通过Portal进行操作,不过可以通过Powershell创建,具体如下: 下载最新的Powershell SDK:http://www.window ...