Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何模拟摄影机应用程序-覆盖方向更改动画?_Ios_Objective C_Swift_Animation_Uikit - Fatal编程技术网

Ios 如何模拟摄影机应用程序-覆盖方向更改动画?

Ios 如何模拟摄影机应用程序-覆盖方向更改动画?,ios,objective-c,swift,animation,uikit,Ios,Objective C,Swift,Animation,Uikit,我正在尝试创建一个视图控制器,非常类似于苹果的摄像头应用程序。请注意,无论您如何打开手机,底部的按键始终固定在home(主页)按钮上。单个元素会旋转和移动以响应,但 主视图保持不变 我怎样才能重新创建它 (来源:) 如果我为我的视图启用方向,当整个视图旋转时,会出现一个很大的分散注意力的动画。我需要东西保持原样 我尝试过禁用视图中的方向更改,并手动设置所有内容的动画,但我需要显示UIAlertController,如果您旋转手机,则警报会倒置或侧向显示 是否有某种方法允许方向更改,但使动画立

我正在尝试创建一个视图控制器,非常类似于苹果的摄像头应用程序。请注意,无论您如何打开手机,底部的按键始终固定在home(主页)按钮上。单个元素会旋转和移动以响应,但 主视图保持不变

我怎样才能重新创建它


(来源:)

如果我为我的视图启用方向,当整个视图旋转时,会出现一个很大的分散注意力的动画。我需要东西保持原样

我尝试过禁用视图中的方向更改,并手动设置所有内容的动画,但我需要显示UIAlertController,如果您旋转手机,则警报会倒置或侧向显示

是否有某种方法允许方向更改,但使动画立即发生?然后我可以同时将元素移动到它们的新位置,它们看起来会保持静止


如果没有,您将如何重新创建iOS摄像头应用程序的方向和布局行为?

以下是从其他各种问题中总结出来的解决方案:

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)

    let duration = coordinator.transitionDuration()
    UIView.animateWithDuration(duration, animations: {
        // things you want to animate go here
        // any animations we kick off before turning them off will continue
    })

    // prevent any animations until this completes
    UIView.setAnimationsEnabled(false)
    coordinator.animateAlongsideTransition({ context in

    }, completion: { context in
        // turn animations back on. 
        UIView.setAnimationsEnabled(true)
    })
}

你看过吗?不,太好了,谢谢!我想我有一个更简单的解决方案,我会在下面发布。