iOS 8和Xcode 6的各种坑

1项目路径坑

模拟器的路径从之前的 ~/Library/Application Support/iPhone Simulator 移动到了 ~/Library/Developer/CoreSimulator/Devices/ 这相当的坑爹,之前运行用哪个模拟器直接选择这个模拟器文件夹进去就能找到项目

现在可好,Devices目录下没有标明模拟器的版本,图片上选中的对应的可能是iPhone 5s 7.1的

然后图片上的文件夹对应的应该是 iPhone 4s 7.1 iPhone 4s 8.0 iPhone 5s 7.1 iPhone 5s 8.0 .......,但是我不知道哪个对应哪个啊,好吧我要疯了

2NSUserDefaults坑

通过 NSUserDefaults 储存在本地的数据,在模拟器删除APP、clean之后无法清空数据,我尝试删除iPhone 4s、iPhone 5s......里面的同一个项目,还是无解,这应该是个BUG,等苹果更新Xcode吧(我目前用的6.0)。但是真机没有这种情况(必须的啊)

3UITableView坑

带有UITableView的界面如果到遇到以下警告

Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell‘s content view. We‘re considering the collapse unintentional and using standard height instead.

添加以下代码可解决

self.tableView.rowHeight = 44.0f;

4autolayout坑

典型的UITabBarController作为根视图,然后点击其中一个页面button的时候push到一个列表页情况,结构如下图

如果在列表页需要隐藏tabbar,那么我一般都会在这个VC把bottombar设置为none以便能更好的进行约束布局,

但是......在调试的时候你会发现进入列表页的瞬间底部会出现一个tabbar高度的视图。还是老老实实在就用默认的Inferred吧。

5键盘弹不出

取消选择Connect Hardware Keyboard

6detailTextLabel无法显示

先来下面这段代码

- (void)viewDidLoad

{

[super viewDidLoad];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

self.array = @[@"测试"];

[self.tableView reloadData];

});

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

return 1;

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

return 1;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TradeRecordCell"

forIndexPath:indexPath];

cell.detailTextLabel.text = _array[indexPath.row];

return cell;

}

代码没什么问题,在iOS 7下,一秒之后cell的detailTextLabel就会显示 测试 两个字,但是在iOS 8却不行detailTextLabel显示为空。测试发现,当detailTextLabel的text一开始为空,iOS 8下运行就会把这个label的size设置(0, 0)从而不能正确显示,原因是这里 cell.detailTextLabel.text = _array[indexPath.row]; 一开始数据就是空的,解决办法:

如果是空就不去设置值

if (_array[indexPath.row]) {

cell.detailTextLabel.text = _array[indexPath.row];

}

或者

cell.detailTextLabel.text = _array[indexPath.row] ? : @" ";

7pch文件不见了

现在Xcode 6创建的项目默认是不带pch文件的,当然了旧版本的项目是会保留的。那么如何添加pch文件?

* Command + N 然后在Other里面选择 PCH File

* 在Build Settings里面找到 Prefix Header

* 添加pch文件,规则是: 项目名/xxxxx.pch

8UIAlertView的坑

UIAlertView显示无标题的长文本问题

UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:nil message:@"远端Git仓库和标准的Git仓库有如下差别:一个标准的Git仓库包括了源代码和历史信息记录。我们可以直接在这个基础上修改代码,因为它已经包含了一个工作副本。"

delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil];

[alterView show];

上面这段代码在iOS 8下显示的样子是这样的,内容完全顶到的顶部,文字还莫名其妙的加粗了

难道我会告诉你只要把title设置为 @"" 就行了吗

UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"" message:@"远端Git仓库和标准的Git仓库有如下差别:一个标准的Git仓库包括了源代码和历史信息记录。我们可以直接在这个基础上修改代码,因为它已经包含了一个工作副本。"

delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil];

[alterView show];

时间: 2024-08-06 13:10:20

iOS 8和Xcode 6的各种坑的相关文章

总结iOS 8和Xcode 6的各种坑

总结iOS 8和Xcode 6的各种坑 项目路径坑 模拟器的路径从之前的 ~/Library/Application Support/iPhone Simulator 移动到了 ~/Library/Developer/CoreSimulator/Devices/ 这相当的坑爹,之前运行用哪个模拟器直接选择这个模拟器文件夹进去就能找到项目 现在可好,Devices目录下没有标明模拟器的版本,图片上选中的对应的可能是iPhone 5s 7.1的 然后图片上的文件夹对应的应该是 iPhone 4s 7

(转)总结iOS 8和Xcode 6的各种坑

项目路径坑 模拟器的路径从之前的 ~/Library/Application Support/iPhone Simulator 移动到了 ~/Library/Developer/CoreSimulator/Devices/ 这相当的坑爹,之前运行用哪个模拟器直接选择这个模拟器文件夹进去就能找到项目 现在可好,Devices目录下没有标明模拟器的版本,图片上选中的对应的可能是iPhone 5s 7.1的 然后图片上的文件夹对应的应该是 iPhone 4s 7.1 iPhone 4s 8.0 iPh

iOS 13.4 & Xcode 11.4 采坑小记(重写系统get)

最近更新了新系统,发现Modal样式设置的UIModalPresentationFullScreen失效了. 相信大家在适配iOS13 系统的时候,为了适配Modal默认样式发生变化( iOS13之前默认为UIModalPresentationFullScreen 13之后变为UIModalPresentationAutomatic)很多人是通过分类方法实现的. 即:为UIViewController扩展该方法(本质是重写modalPresentationStyle属性的get方法),这样所有地

文顶顶 iOS开发UI篇—IOS开发中Xcode的一些使用技巧

iOS开发UI篇—IOS开发中Xcode的一些使用技巧 一.快捷键的使用 经常用到的快捷键如下: 新建 shift + cmd + n     新建项目 cmd + n             新建文件 视图 option + cmd + 回车 打开助理编辑器 cmd + 回车           显示主窗口 cmd + 0             导航窗口 option + cmd + 0    工具窗口 在.m & .h之间切换           control + cmd + 上/下 按

iOS开发UI基础—IOS开发中Xcode的一些使用技巧

iOS开发UI基础-IOS开发中Xcode的一些使用技巧 一.快捷键的使用 经常用到的快捷键如下: 新建 shift + cmd + n     新建项目 cmd + n             新建文件 视图 option + cmd + 回车 打开助理编辑器 cmd + 回车           显示主窗口 cmd + 0             导航窗口 option + cmd + 0    工具窗口 在.m & .h之间切换           control + cmd + 上/下

【三分钟视频教程】iOS开发中 Xcode 报 apple-o linker 错误的#解决方案#

[三分钟视频教程]iOS开发中 Xcode 报 apple-o linker 错误的#解决方案# [三分钟视频教程]iOS开发中 Xcode 报 apple-o linker 错误的#解决方案#,布布扣,bubuko.com

《iOS开发全然上手——使用iOS 7和Xcode 5开发移动与平板应用》之Objective-C新手训练营

编写Hello World应用程序通常被觉得,是学习不论什么编程语言的第一步.在这一章,你将创建iOS版的Hello World应用程序作为起步,高速了解Xcode这个开发iOS应用程序的主要工具. 下一步.你将学习Objective-C的基础知识.在此基础之上.将探索类(class)与对象(object)的知识.它们是构建应用程序的主要基石.与此同一时候,你将创建CarValet应用程序,练习一些类的编写.并学习属性(property)的知识.在本章末尾,你将在指导下完毕编程挑战题以探索子类扩

iOS修改默认Xcode版本的方法

电脑中装了二个xcode版本,一个是xcode6-beta,一个是xcode5.1.1,每次打开工程时,默认是用xcode6-beta打开.在简介中修改打开方式也没用,没来在stackoverflow中找到答案 After reading about LaunchServices in OS X I have finally found the solution, thanks for the hint @peter-m. To modify files association for cert

Send Push Notifications to iOS Devices using Xcode 8 and Swift 3, APNs Auth Key

Send Push Notifications to iOS Devices using Xcode 8 and Swift 3 OCT 6, 2016 Push notifications are a great way to ensure your users re-engage with your app every once in a while, but implementing them on iOS can be challenging, especially with all o