AutoLayout CGAffine转换iOS7 iOS8

Ala*_*lak 3 storyboard cgaffinetransform autolayout ios7 ios8

几个小时以来,我一直试图弄清楚为什么autolayout在我应用CGAffineTransformMakeScale时在iOS8中突破了我的约束而在iOS7中没有.(我使用Xcode 6.0.1(6A317)与Storyboard和Autolayout).

代码 :

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];
}];
Run Code Online (Sandbox Code Playgroud)

iOS7结果:

在此输入图像描述

iOS8结果:

在此输入图像描述

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)-|>"
)
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

奥洛克

Pbk*_*Pbk 7

CGAffineTransformIdentity在ios​​7和ios8上的行为有所不同.这与自动布局和大小类有关.解决方案是删除与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
}
Run Code Online (Sandbox Code Playgroud)