Ios 两个模式显示的视图控制器-同时关闭
在我的应用程序中有三个视图控制器;白色、红色和蓝色。白色是应用程序的主视图 点击按钮时,白色模式表示红色。红色代表蓝色。一切都很好。例如,蓝色有一些表单供用户填写,然后用户点击蓝色 蓝色希望将用户返回到主UI,白色。当用户点击Disclose时,将运行:Ios 两个模式显示的视图控制器-同时关闭,ios,uikit,Ios,Uikit,在我的应用程序中有三个视图控制器;白色、红色和蓝色。白色是应用程序的主视图 点击按钮时,白色模式表示红色。红色代表蓝色。一切都很好。例如,蓝色有一些表单供用户填写,然后用户点击蓝色 蓝色希望将用户返回到主UI,白色。当用户点击Disclose时,将运行: @IBAction func didTapDismissBoth(sender: AnyObject) { let red = presentingViewController! let white = red.present
@IBAction func didTapDismissBoth(sender: AnyObject) {
let red = presentingViewController!
let white = red.presentingViewController!
white.dismissViewControllerAnimated(true, completion: nil)
}
红色和蓝色确实会解散,但蓝色会立即消失,红色会被视为解散动画!当慢速动画打开时,红色闪烁在视觉上是不和谐的,并且很容易在模拟器中看到
我宁愿看到蓝色优雅地从屏幕上滑下,露出白色
当红色从蓝色回到白色时,我能阻止红色抬起它丑陋的头吗?我能够通过(在IB中)将红色的呈现样式设置为“过当前上下文”来模拟我想要的效果。这告诉UIKit保持红色的父视图(白色)在周围,因此,如果红色的视图中有透明度,则白色将显示出来 在解雇过程中,我将红色设置为完全透明,并设置蓝色动画
@IBAction func didTapDismissBoth(sender: AnyObject) {
let red = presentingViewController!
let white = red.presentingViewController!
red.view.alpha = 0 // Red presents "over current context" so white's view still exists. White's view will show through this transparent red
red.dismissViewControllerAnimated(true, completion: { // dismiss blue, revealing transparent red & white showing through
white.dismissViewControllerAnimated(false, completion: nil) }) // dismiss red with no animation
}
虽然这隐藏了红色闪烁的问题,但并不能解释动画过程;这意味着怀特的观点不必要地停留在周围。我能够通过(在IB中)将瑞德的表达风格设置为“在当前背景下”来模拟我想要的效果。这告诉UIKit保持红色的父视图(白色)在周围,因此,如果红色的视图中有透明度,则白色将显示出来 在解雇过程中,我将红色设置为完全透明,并设置蓝色动画
@IBAction func didTapDismissBoth(sender: AnyObject) {
let red = presentingViewController!
let white = red.presentingViewController!
red.view.alpha = 0 // Red presents "over current context" so white's view still exists. White's view will show through this transparent red
red.dismissViewControllerAnimated(true, completion: { // dismiss blue, revealing transparent red & white showing through
white.dismissViewControllerAnimated(false, completion: nil) }) // dismiss red with no animation
}
虽然这隐藏了红色闪烁的问题,但并不能解释动画过程;这意味着怀特的观点不必要地停留在周围。我会使用展开分段来实现这一点。你正在使用故事板,为什么不利用它呢。只需创建一个从蓝色视图控制器到白色视图控制器的展开段,您就完成了。我将使用展开段进行此操作。你正在使用故事板,为什么不利用它呢。只需创建一个从蓝色视图控制器到白色视图控制器的放松段,您就完成了。好主意。试过了;同样的结果!红色闪光。哦,你也可以看看
shouldAutomaticallyForwardAppearanceMethods()
,我现在没有时间尝试。好主意。试过了;同样的结果!红色闪光。哦,你也可以看看shouldlautomaticallyforwardappearancemethods()
,我现在没有时间尝试。