iOS 8与xcode6的变化 总结

今天给朋友解决问题的时候 发现iOS 8和xcode6 和 以前的版本有许多不同,大神的目前的总结如下:

项目路径坑

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

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

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

NSUserDefaults坑

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

UITableView坑

带有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;autolayout坑

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

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

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

键盘弹不出

取消选择Connect Hardware Keyboard

detailTextLabel无法显示

先来下面这段代码

– (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] ? : @" ";pch文件不见了

现在Xcode 6创建的项目默认是不带pch文件的,当然了旧版本的项目是会保留的。那么如何添加pch文件?* Command + N 然后在Other里面选择PCH File* 在Build Settings里面找到Prefix Header

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

UIAlertView的坑

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

@@, nil];[alterView show];

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

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

@, nil];[alterView show];

宁愿停歇在你门前的那棵树上,看着你,守护你。

iOS 8与xcode6的变化 总结

相关文章:

你感兴趣的文章:

标签云: