I am using following code to present a view controller modally. I have changed presentation style to "Over current Context". It works fine on iOS 8 but screen gets black on os < 8. I know Over Current Context is available only in iOS 8. My question is how can I achieve this in iOS 7.
let vc = self.storyboard.instantiateViewControllerWithIdentifier("markerView") as! MarkerViewController
self.presentViewController(vc, animated: false, completion: nil)
This second controller has a dismiss option that just comes back to the root view controller and a button that when the user touches it dismisses the current view controller so it goes back to the root view controller for a second and presents another one.
You have to use Current Context
for iOS 7.
To check the iOS-Version you can use NSFoundationVersionNumber
.
let iOS7 = floor(NSFoundationVersionNumber) <= floor(NSFoundationVersionNumber_iOS_7_1)
let iOS8 = floor(NSFoundationVersionNumber) > floor(NSFoundationVersionNumber_iOS_7_1)
Then you can check which version is running and use OverCurrentContext
or CurrentContext
.
if iOS8 {
self.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
} else {
self.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With