Ios 使用AutoLayout添加包含内容的UIViewController时,内容的动画不起作用

Ios 使用AutoLayout添加包含内容的UIViewController时,内容的动画不起作用,ios,swift,ipad,autolayout,core-animation,Ios,Swift,Ipad,Autolayout,Core Animation,我有一个UIViewController,我正在将它作为子视图添加到我的iPad应用程序中。UIViewcontroller有一个UITableView,其大小根据情节提要中的自动布局集进行调整。我想展示将此视图从iPad的中心移动到右端(横向模式)的动画。为此,我最初将宽度设置为0,并在动画块中增加它。尽管动画效果良好,但UIViewController中的tableview是在动画之前添加的。所以它没有动画。它还应该与其父对象(UIViewController)展开。我的代码: @IBAct

我有一个UIViewController,我正在将它作为子视图添加到我的iPad应用程序中。UIViewcontroller有一个UITableView,其大小根据情节提要中的自动布局集进行调整。我想展示将此视图从iPad的中心移动到右端(横向模式)的动画。为此,我最初将宽度设置为0,并在动画块中增加它。尽管动画效果良好,但UIViewController中的tableview是在动画之前添加的。所以它没有动画。它还应该与其父对象(UIViewController)展开。我的代码:

@IBAction func tappedNotifications(_ sender: UIButton) {
    let storyboard = UIStoryboard(name: "Content_iPad", bundle: nil)
    let notificationSettingsVC = storyboard.instantiateViewController(withIdentifier:"SettingsViewController_iPad")
    notificationSettingsVC.view.frame = CGRect(x: 380, y: 0, width: 0, height: 775)
    self.view.addSubview(notificationSettingsVC.view)
    notificationSettingsVC.didMove(toParentViewController: self)

    UIView.animate(withDuration: 0.7, animations: {
        notificationSettingsVC.view.frame = CGRect(x: 380, y: 0, width: 0, height: 775)
        notificationSettingsVC.view.frame = CGRect(x: 380, y: 0, width: 570, height: 775)
        notificationSettingsVC.view.setNeedsLayout()
    }, completion: {
        (completed) -> Void in

    })
}

看起来您正在告诉通知视图控制器将其宽度设置为0和570,请尝试删除将宽度设置为0的帧更改

@IBAction func tappedNotifications(_ sender: UIButton) {
    let storyboard = UIStoryboard(name: "Content_iPad", bundle: nil)
    let notificationSettingsVC = storyboard.instantiateViewController(withIdentifier:"SettingsViewController_iPad")
    notificationSettingsVC.view.frame = CGRect(x: 380, y: 0, width: 0, height: 775)
    self.view.addSubview(notificationSettingsVC.view)
    notificationSettingsVC.didMove(toParentViewController: self)

    UIView.animate(withDuration: 0.7, animations: {
        notificationSettingsVC.view.frame = CGRect(x: 380, y: 0, width: 570, height: 775)
        notificationSettingsVC.view.setNeedsLayout()
    }, completion: {
        (completed) -> Void in

    })
}

在Notification上执行animatio SettingSVC controller on ViewWillExample()方法其工作精细度仍然不工作,我相信问题是因为我使用了来自情节提要的视图,而不是通过编码创建的。您能否提供有关如何在情节提要中设置视图控制器的更多信息,例如视图控制器内的表视图上使用的约束等