【问题标题】:Switching between views in a Storyboard [duplicate]在情节提要中的视图之间切换[重复]
【发布时间】:2020-04-17 08:38:14
【问题描述】:

问题:

在顶部,您可以看到旧视图,如果您按住第二个视图的顶部并移动到底部,则第二个视图会消失。 我希望第二个视图覆盖第一个视图。 第一个视图有一个带有操作的按钮:

@IBaction func test() {
    let vc = self.storyboard!.instantiateViewController(withIdentifier: "ccc")
    self.show( vc, sender: nil )
}

【问题讨论】:

  • 你为什么不用present
  • 我尝试了 self.present(vc, animated: true) 但得到了相同的结果
  • @aaa55 检查我的答案
  • 这能回答你的问题吗? Presenting modal in iOS 13 fullscreen
  • 是的,非常感谢,花了好几个小时才弄明白

标签: ios swift xcode


【解决方案1】:

只需将modalPresentationStyle 更改为.fullScreen

//1
let vc = self.storyboard!.instantiateViewController(withIdentifier: "ccc")

//2
vc.modalPresentationStyle = .fullScreen

//3
self.present(vc, animated: true, completion: nil)

【讨论】:

  • 它的工作谢谢,我还不能验证答案但是当 modalPresentationStyle 未指定时,xcode 随机选择?
  • 不是随机的。它现在是 iOS 13.0+ 的默认演示样式,对于以下版本,它仍然默认在全屏上显示它们。
猜你喜欢
  • 1970-01-01
  • 2015-06-12
  • 1970-01-01
  • 2012-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多