viewcontroller

How to dismiss ViewController in Swift?

蹲街弑〆低调 提交于 2019-11-26 19:18:27
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? Zoon Nooz From you image it seems like you presented the ViewController using push The dismissViewControllerAnimated is used to close

Dismiss more than one view controller simultaneously

寵の児 提交于 2019-11-26 19:18:14
问题 I'm making a game using SpriteKit. I have 3 viewControllers: selecting level vc, game vc, and win vc. After the game is over, I want to show the win vc, then if I press OK button on the win vc, I want to dismiss the win vc AND the game vc (pop two view controllers out of the stack). But I don't know how to do it because if I call self.dismissViewControllerAnimated(true, completion: {}) the win vc (top of the stack) is dismissed, so I don't know where to call it again to dismiss the game vc.

Only ONE VIEW landscape mode

安稳与你 提交于 2019-11-26 18:30:42
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 UIViewController manually? Zedenem I am gonna suppose you are targeting iOS 7 here (using XCode 5.1, I think I am

iOS Nested View Controllers view inside UIViewController's view?

我是研究僧i 提交于 2019-11-26 17:55:16
问题 Is it typically bad programming practice in iOS to have a nested view controller's view inside UIViewController's view? Say for instance I wanted to have some kind of interactive element that responds to user's touches, but only takes up maybe 25% of the screen. I suppose I would add this nested view controller to my UIViewController by saying something like: [self.view addSubview: nestedViewController.view]; 回答1: No, this is generally good design, it helps keep your view controllers concise.

How can I use a variable from another Controller in JavaFX

拥有回忆 提交于 2019-11-26 16:56:36
问题 I have two scenes Login.fxml and MainView.fxml and two diferent controllers LoginController.java and MainViewControler.java In LoginController I do the whole process to login and get the value of JSessionID and store it in a object, like below: loginGateway = loginGateway(gateway); Now in MainViewController I need to use the this object (loginGateway) to getJSessionID and make other requests to the server. But how can I acess this object in another Controller Class (MainViewController.java) ?

Switching Views Programmatically in Swift

筅森魡賤 提交于 2019-11-26 16:37:58
问题 I am trying to switch to the second view by pressing the "feeling lucky" button. When I try out my simulator and press it, it just goes to a black screen. How could I fix this? @IBAction func FeelingLuckyPress(sender: UIButton) { let secondViewController:SecondViewController = SecondViewController() self.presentViewController(secondViewController, animated: true, completion: nil) } 回答1: You can add a segue between the two scenes in your storyboard by control dragging from the view controller

force landscape ios 7

筅森魡賤 提交于 2019-11-26 15:56:18
问题 I've tried to following methods to force landscape on one my views: - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeLeft; } - (BOOL)shouldAutorotate{ return YES; } Neither did work. Note that I'm testing on the simulator and on an iPad. Thanks 回答1: Here is how I forced one of my views to be Landscape using NavigationViewController:

Get the top ViewController in iOS Swift

你说的曾经没有我的故事 提交于 2019-11-26 14:37:51
问题 I want to implement a separate ErrorHandler class, which displays error messages on certain events. The behavior of this class should be called from different other classes. When an error occurs, it will have an UIAlertView as output. The display of this AlertView should ALWAYS be on top. So no matter from where the Error gets thrown, the topmost viewController should display the AlertMessage (e.g. when an asynchronous background process fails, I want an error message, no matter what View is

Swift presentViewController

谁说胖子不能爱 提交于 2019-11-26 11:59:08
问题 I programatically have multiple View Controllers in an iOS Swift Project. I do not have the storyboards and would like to avoid them if possible. Is there a way to switch to another viewcontroller.swift file (We will call it view2.swift ) and have it be part of a function that a button calls? I have tried the following: let storyboard: UIStoryboard = UIStoryboard(name: \"myTabBarName\", bundle: nil) let vc: UIViewController = storyboard.instantiateViewControllerWithIdentifier(\"myVCID\") as

Swift programmatically navigate to another view controller/scene

妖精的绣舞 提交于 2019-11-26 08:49:42
问题 I\'m using following code to programmatically navigate to another ViewController. It works fine, but it some how hides the navigation bar . How do I fix this? (the navigation bar is created by embeding the ViewController in the navigation controller if that matters.) let storyBoard : UIStoryboard = UIStoryboard(name: \"Main\", bundle:nil) let nextViewController = storyBoard.instantiateViewControllerWithIdentifier(\"nextView\") as NextViewController self.presentViewController