约束更改时的自动布局UIView不会为iOS 7设置动画

约束更改时的自动布局UIView不会为iOS 7设置动画,ios,iphone,ios7,ios8,autolayout,Ios,Iphone,Ios7,Ios8,Autolayout,我正在尝试使用自动布局从“自下而上”设置视图动画 这在iOS 8中非常有效,但是在iOS 7中没有动画效果 以下是一段代码片段: @interface ViewController () @property (strong) AViewController *aVC; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.aVC = [[AViewControll

我正在尝试使用自动布局从“自下而上”设置视图动画

这在iOS 8中非常有效,但是在iOS 7中没有动画效果

以下是一段代码片段:

@interface ViewController ()
@property (strong) AViewController *aVC;
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.aVC = [[AViewController alloc] init];
    self.aVC.view.translatesAutoresizingMaskIntoConstraints = NO;
    [self.view addSubview:self.aVC.view];
    [self.aVC.view autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:0];
    [self.aVC.view autoSetDimension:ALDimensionHeight    toSize:100];
    [self.aVC.view autoSetDimension:ALDimensionWidth     toSize:320];
     NSLayoutConstraint *constraint = [self.aVC.view autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:-100];
     [self.view layoutIfNeeded];
    [UIView animateWithDuration:2 animations:^{
        constraint.constant = -25;
        [self.view layoutIfNeeded];
    }];

}
我正在使用great类别,以便轻松添加约束

连接-将在iOS 8模拟器上工作,而不是在iOS 7模拟器上工作


关于如何在iOS 7上执行此操作的任何建议?

如果您将
[self.view layoutifneed]
替换为
[self.aVC.view layoutifneed]
,则这两个iOS版本都适用。我不知道具体的原因

编辑

请试试这样的

[self.aVC.view layoutIfNeeded];
[UIView animateWithDuration:2 animations:^{
    constraint.constant = -25;
    [self.view layoutIfNeeded];
}];

如果将
[self.aVC.view layoutifneed]
替换为
[self.aVC.view layoutifneed]
,它将在两个iOS版本上都能工作。我不知道具体的原因

编辑

请试试这样的

[self.aVC.view layoutIfNeeded];
[UIView animateWithDuration:2 animations:^{
    constraint.constant = -25;
    [self.view layoutIfNeeded];
}];

请看我的最新问题;它不适用于包含子视图的xib。我下载了旧的,它适合我。您是否修改了xib中的任何内容?是的,它在第一次提交时使用了空的xib。我在xib中添加了一个标签和两个图像,现在它在iOS 7上没有动画。谢谢。请看我更新的问题;它不适用于包含子视图的xib。我下载了旧的,它适合我。您是否修改了xib中的任何内容?是的,它在第一次提交时使用了空的xib。我在xib中添加了一个标签和两个图像,现在它在iOS 7上没有动画。谢谢