模态视图正在重置我现有的视图控制器

时间:2013-08-03 00:02:46

标签: animation modal-dialog uistoryboard redraw

我在UIStoryboard中使用segue在我的代码中加载了一个视图控制器。基于一些用户选择的选项,然后我使用动画隐藏或显示UI控件。一切正常。

- (void)showComments {
    NSLog(@"Show Comments");
    _commentsTextView.hidden = NO;
    _commentsTextView.frame = CGRectMake(435, 266, 475, 134);

    [UIView animateWithDuration:1 animations:^{
        _commentsTextView.alpha = 1;
        _signatureButton.frame = CGRectMake(435, 420, 475, 134);
        _cancelButton.frame = CGRectMake(568, 581, 100, 44);
        _finishedButton.frame = CGRectMake(676, 581, 100, 44);
    }];

}

然后我使用以下代码呈现在UIStoryboard中创建的视图控制器:

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];

    SigningViewController *signingVC = (SigningViewController *)[storyboard instantiateViewControllerWithIdentifier:@"SigningViewController"];
    signingVC.object = self;
    signingVC.signatureProperty = @"employeeSignature";
    signingVC.startDate = self.startDate;
    signingVC.endDate = self.endDate;

    [self presentViewController:signingVC animated:YES completion:nil];

当此代码触发时,所有内容都按预期发生,除了一件事:隐藏或显示UI控件的所有自定义动画都会恢复。就好像通过调用presentViewController方法一样,它正在从UIStoryboard重绘现有视图。

在以模态方式显示新视图之前,有没有办法让它退出重绘/重新加载我的现有视图?

2 个答案:

答案 0 :(得分:0)

我也有同样的问题。无论我试图在模态关闭时改变动画,它似乎都会重置回原始故事板。

我必须使用的解决方案是将任何动画视图添加为头文件的插座。从故事板上的视图控制器的self.view或主视图中取出视图,并以编程方式将其添加为子视图。将框架设置到您想要的位置,并且在结束模态后,所有动画位置应该相同。如果您需要更多解释并让我知道,它对我有用。

答案 1 :(得分:0)

我遇到了同样的问题并以更详细的形式发布在这里,名为kokx的用户帮助了我很多,答案记录在my question page中。

相关问题