Existing view controller versus current context programmatically using fast

I use the following code to represent a view controller modulo. I changed the presentation style to "Over current Context". It works fine on iOS 8, but the screen goes black on os <8. I know that the current context is only available 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)

+5
source share
1 answer

You must 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 } 
+10
source

Source: https://habr.com/ru/post/1213122/


All Articles