【问题标题】:Present view controller modally over current context programmatically using swift使用 swift 以编程方式在当前上下文中模态显示视图控制器
【发布时间】:2015-02-11 10:50:41
【问题描述】:

我正在使用以下代码以模态方式呈现视图控制器。我已将演示样式更改为“当前上下文”。它在 iOS 8 上运行良好,但在 os

let vc = self.storyboard.instantiateViewControllerWithIdentifier("markerView") as! MarkerViewController

self.presentViewController(vc, animated: false, completion: nil)

【问题讨论】:

    标签: ios swift


    【解决方案1】:

    对于 iOS 7,您必须使用 Current Context

    要检查 iOS 版本,您可以使用 NSFoundationVersionNumber

    let iOS7 = floor(NSFoundationVersionNumber) <= floor(NSFoundationVersionNumber_iOS_7_1)
    let iOS8 = floor(NSFoundationVersionNumber) > floor(NSFoundationVersionNumber_iOS_7_1)
    

    然后你可以检查哪个版本正在运行并使用OverCurrentContextCurrentContext

    if iOS8 {
      self.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
    } else {
      self.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
    }
    

    【讨论】:

    • 对我不起作用。仍然在 iOS 7 屏幕是黑色的。
    • 在 iOS7 中,您必须在演示者上设置演示样式。总的来说,这些 iOS 检查似乎是有问题的,对 7.2 的更新会打破这两种情况。
    • 在标签栏控制器中 .overCurrentContext 不覆盖标签栏。 .overFullScreen 解决了这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    • 1970-01-01
    相关资源
    最近更新 更多