自动版式CGAffineTransform iOS7 iOS8上 [英] AutoLayout CGAffineTransform iOS7 iOS8

查看:172
本文介绍了自动版式CGAffineTransform iOS7 iOS8上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关小时我一直在试图找出为什么自动布局是打破我的iOS8上的约束,但不是在iOS7当我申请CGAffineTransformMakeScale。 (我使用的是X code 6.0.1(6A317)与故事板和自动布局)。

For hours I've been trying to figure why autolayout is breaking my constraint in iOS8 but not in iOS7 when I apply CGAffineTransformMakeScale. (I use Xcode 6.0.1 (6A317) with Storyboard and Autolayout).

在code:

TCTGridController *gridController = self.gridController;
stackController.view.frame = gridController.view.frame;
stackController.stackCollectionView.transform = CGAffineTransformMakeScale(0.1, 0.1);

[gridController.view.superview addSubview:stackController.view];

[UIView animateWithDuration:0.2 animations:^{
    stackController.stackCollectionView.transform = CGAffineTransformMakeScale(1, 1);
    [stackController.stackCollectionView layoutIfNeeded];
} completion:^(BOOL finished) {
    [stackController didMoveToParentViewController:self];
}];

iOS7结果是:

iOS7 result :

iOS8上的结果是:

iOS8 result :

iOS8上的约束错误:

Constraint error on iOS8 :

(
"<NSLayoutConstraint:0x7fa126a9b100 V:[_UILayoutGuide:0x7fa126a9a900]-(120)-[TCTCollectionView:0x7fa125139400]>",
"<_UILayoutSupportConstraint:0x7fa126a8b500 V:[_UILayoutGuide:0x7fa126a9a900(0)]>",
"<_UILayoutSupportConstraint:0x7fa126a8a960 V:|-(0)-[_UILayoutGuide:0x7fa126a9a900]   (Names: '|':UIView:0x7fa126a9a810 )>",
"<NSAutoresizingMaskLayoutConstraint:0x7fa126c86840 h=--- v=--- 'UIView-Encapsulated-Layout-Top' V:[UIView:0x7fa126a9a810]-(0)-|>"
)

任何想法?

奥洛克

推荐答案

CGAffineTransformIdentity行为不同的ios7和iOS8上。这与自动布局和大小班做。解决的办法是去除约束,与上ios7动画冲突

CGAffineTransformIdentity behaves differently on ios7 and ios8. This has to do with auto-layout and size classes. The solution is to remove constraints that conflict with the animation on ios7.

// solve the constraint-animation problem
if(NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) {
    // iOS7 remove constraints that conflict with animation
    if (self.centerYAlignment != nil) {
    self.view.removeConstraint(self.centerYAlignment) //is an IBOutlet 
    }
} else {
    // iOS8 constraint animations are fine
}

这篇关于自动版式CGAffineTransform iOS7 iOS8上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆