viewcontroller

How to dismiss ViewController in Swift?

我是研究僧i 提交于 2019-11-26 06:54:12
问题 I am trying to dismiss a ViewController in swift by calling dismissViewController in an IBAction @IBAction func cancel(sender: AnyObject) { self.dismissViewControllerAnimated(false, completion: nil) println(\"cancel\") } @IBAction func done(sender: AnyObject) { self.dismissViewControllerAnimated(false, completion: nil) println(\"done\") } I could see the println message in console output but ViewController never gets dismissed. What could be the problem? 回答1: From you image it seems like you

How to Navigate from one View Controller to another using Swift

こ雲淡風輕ζ 提交于 2019-11-26 06:27:05
问题 I\'d like to navigate from one view controller to another. How can I convert the following Objective-C code into Swift? UIViewController *viewController = [[self storyboard] instantiateViewControllerWithIdentifier:@\"Identifier\"]; UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:viewController]; [self.navigationController pushViewController:navi animated:YES]; 回答1: Create a swift file (SecondViewController.swift) for the second view controller and in

Only ONE VIEW landscape mode

心已入冬 提交于 2019-11-26 06:20:48
问题 I finished my iOS app but I need to set only ONE view to landscape mode, the rest of the views can only be seen in portrait mode. I\'m using Xcode 5.1 and I created all of my Views by dropping in my storyboard View Controllers from the right panel, so if you are going to tell me to write some code somewhere, please tell me exactly where I need to write it. I read one solution here UINavigationController Force Rotate but I don\'t know where to write that code. Do I need to create one

Presenting modal in iOS 13 fullscreen

北城以北 提交于 2019-11-25 22:04:07
问题 In iOS 13 Beta 1 there is a new behaviour for modal view controller when being presented. Now it\'s not fullscreen by default and when I try to slide down, the app just dismiss the View Controller automatically. How can I prevent this behaviour and get back to the old good fullscreen modal vc? Thanks 回答1: 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