Swift presentViewController
Try this: let vc = ViewController() //change this to your class name self.presentViewController(vc, animated: true, completion: nil) With Swift3: self.present(vc, animated: true, completion: nil)
Try this: let vc = ViewController() //change this to your class name self.presentViewController(vc, animated: true, completion: nil) With Swift3: self.present(vc, animated: true, completion: nil)
I just created a tutorial for interactively dragging down a modal to dismiss it. http://www.thorntech.com/2016/02/ios-tutorial-close-modal-dragging/ I found this topic to be confusing at first, so the tutorial builds this out step-by-step. If you just want to run the code yourself, this is the repo: https://github.com/ThornTechPublic/InteractiveModal This is the approach I used: View Controller You override … Read more
Swift 5 The default modal presentation style is a card. This shows the previous view controller at the top and allows the user to swipe away the presented view controller. To retain the old style you need to modify the view controller you will be presenting like this: newViewController.modalPresentationStyle = .fullScreen This is the same … Read more
Swift AppDelegate.swift internal var shouldRotate = false func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return shouldRotate ? .allButUpsideDown : .portrait } Your landscape view controller let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.shouldRotate = true // or false to disable rotation Objective-C AppDelegate.h @property (assign, nonatomic) BOOL shouldRotate; AppDelegate.m – (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow … Read more
From you image it seems like you presented the ViewController using push The dismissViewControllerAnimated is used to close ViewControllers that presented using modal Swift 2 navigationController.popViewControllerAnimated(true) Swift 4 navigationController?.popViewController(animated: true) dismiss(animated: true, completion: nil)
Create a swift file (SecondViewController.swift) for the second view controller and in the appropriate function type this: let secondViewController = self.storyboard.instantiateViewControllerWithIdentifier(“SecondViewController”) as SecondViewController self.navigationController.pushViewController(secondViewController, animated: true) Swift 2+ let mapViewControllerObj = self.storyboard?.instantiateViewControllerWithIdentifier(“MapViewControllerIdentifier”) as? MapViewController self.navigationController?.pushViewController(mapViewControllerObj!, animated: true) Swift 4 let vc = UIStoryboard.init(name: “Main”, bundle: Bundle.main).instantiateViewController(withIdentifier: “IKDetailVC”) as? IKDetailVC self.navigationController?.pushViewController(vc!, animated: true)
With iOS 13, as stated in the Platforms State of the Union during the WWDC 2019, Apple introduced a new default card presentation. In order to force the fullscreen you have to specify it explicitly with: let vc = UIViewController() vc.modalPresentationStyle = .fullScreen //or .overFullScreen for transparency self.present(vc, animated: true, completion: nil)