在其他ViewController视图上添加时无法调整ViewController的视图大小

时间:2014-08-08 09:34:44

标签: ios objective-c animation viewcontroller

我正在使用故事板从编码中添加视图控制器的视图到其他视图控制器的视图(内容视图),现在的问题是我有一些动画应用于内容视图,在我正在调整帧的大小,实际上并没有工作。我的代码是 -

UIViewController *tempVC=[self.storyboard instantiateViewControllerWithIdentifier:@"TempVC"];
[self addChildViewController:tempVC];

tempVC.view.frame=self.contentView.frame;
[self.contentView addSubview:tempVC.view];

和动画代码是

- (IBAction)xClicked:(id)sender {

CGRect swapperRect=self.swapperView.frame;
swapperRect.origin.y=114;
swapperRect.size.height=340;

CGRect menuFrame=self.menuView.frame;
menuFrame.origin.x=0;

CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -1000.0;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, -M_PI * 0.2, 0.0f, 1.0f, 0.0f);

[UIView animateWithDuration:1.0 animations:^{

    self.swapperView.frame=swapperRect;

    self.swapperView.layer.anchorPoint = CGPointMake(0.5, 0.5);
    self.swapperView.layer.transform = rotationAndPerspectiveTransform;

} completion:^(BOOL finished){
    // code to be executed when flip is completed
    [UIView animateWithDuration:1.0 animations:^{
        self.menuView.frame=menuFrame;
        self.swapperView.center=CGPointMake(330, 284);
    }];
}];

}

enter image description here

问题可以看出,必须调整正确的视图大小,即没有发生。

1 个答案:

答案 0 :(得分:0)

关闭该视图的自动布局,或使用AutoLayout调整代码进行取景。