presentviewcontroller

Adding a view to the window hierarchy

故事扮演 提交于 2019-11-29 14:55:17
问题 I am trying to create a pause screen on my game. I have added a 'PauseScreen' viewController in my storyboard with the Storyboard ID and Restoration ID set as "PauseScreenID" and to move to the pause screen I have have created the function in "GameScene" : func pauseSceenTransition(){ let viewController = UIStoryboard(name: "Main", bundle:nil).instantiateViewControllerWithIdentifier("PauseScreenID") as UIViewController let currentViewController = (UIApplication.sharedApplication().delegate as

Present a view controller, dismiss it and present a different one in Swift

前提是你 提交于 2019-11-29 03:06:32
问题 So I have a root view controller that has a button that when the user pushes it, another view controller is presented. 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. Going to the first controller I use: let vc = FirstController() self.present(vc, animated: true, completion: nil) And

KEEP keyboard ON when UIAlertcontroller is presented in Swift?

…衆ロ難τιáo~ 提交于 2019-11-29 02:33:10
问题 When the alert pops up the keyboard is dismissed. I have looked everywhere but did not find solutions to keep the keyboard visible. When alert is presented the textfield seems to resign first responder automatically as the alert is presented modally. How is it possible to keep the keyboard behind this alert which means the textfield still editing even if no interaction will be possible ? 回答1: This solution works for me: let rootViewController: UIViewController = UIApplication

iOS: Warning “attempt to present ViewController whose view is not in the window hierarchy”

巧了我就是萌 提交于 2019-11-28 19:07:30
I am getting following warning when I try to present a ActivityController on navigation controller, Attempt to present <UIActivityViewController: 0x15be1d60> on <UINavigationController: 0x14608e80> whose view is not in the window hierarchy! I have tried to present view controller by following code, UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities]; activityController.excludedActivityTypes = excludeActivities; UIViewController *vc = self.view.window.rootViewController; [vc

iOS: present view controller programmatically

一曲冷凌霜 提交于 2019-11-28 03:57:15
I'm using the presentViewController:animated:completion: method to go to another view controller. This is my code: AddTaskViewController *add = [[AddTaskViewController alloc] init]; [self presentViewController:add animated:YES completion:nil]; This code goes to the other UIViewController but the other controller is empty. I've always been using storyboards but now I need this to be done in code. If you're using a storyboard, you probably shouldn't be using alloc and init to create a new view controller. Instead, look at your storyboard and find the segue that you want to perform; it should

iOS: Warning “attempt to present ViewController whose view is not in the window hierarchy”

▼魔方 西西 提交于 2019-11-27 20:28:05
问题 I am getting following warning when I try to present a ActivityController on navigation controller, Attempt to present <UIActivityViewController: 0x15be1d60> on <UINavigationController: 0x14608e80> whose view is not in the window hierarchy! I have tried to present view controller by following code, UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities]; activityController

Present a modal view controller with transparent background

拟墨画扇 提交于 2019-11-27 13:46:07
I want to present a UIViewController programmatically which should show up (or not, rather) with transparent background. I want it for iOS 7.0 and above. I've find myself many questions (and answers) but they weren't able to help me. Here's the view hierarchy of my app. I'm using a side menu controller (RESideMenu). I have a rootView (base from RESideMenu) -> Showing a Center controller (along with a left view controller) in UINavigationController . In requirements, I'd like to present a view controller From a pushed view controller (in navigational hierarchy) From a presented view controller

Swift presentViewController

时光毁灭记忆、已成空白 提交于 2019-11-27 10:50:37
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 UIViewController self.presentViewController(vc, animated: true, completion: nil) The above works with

How to call a View Controller programmatically?

与世无争的帅哥 提交于 2019-11-27 10:33:18
I have looked at all the tutorials I can find on this one, and I still don't have the answer. I need to call another view from the code. I am using UIStoryboards . I have changed the view many times by control-dragging from UIButtons , but now it must be from the code. I am trying to call the info page from the main menu if it is the first time the user has opened the app. I cannot seem to find a way to change the views from the code, however. All my views are controlled by the same files ( ViewController2 ). The identifier of my main menu is ViewControllerMain , and the identifier of the info

Warning: Attempt to present * on * whose view is not in the window hierarchy - swift

偶尔善良 提交于 2019-11-27 03:05:57
I'm trying to present a ViewController if there is any saved data in the data model. But I get the following error: Warning: Attempt to present * on *whose view is not in the window hierarchy" Relevant code: override func viewDidLoad() { super.viewDidLoad() loginButton.backgroundColor = UIColor.orangeColor() var request = NSFetchRequest(entityName: "UserData") request.returnsObjectsAsFaults = false var appDel:AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate) var context:NSManagedObjectContext = appDel.managedObjectContext! var results:NSArray = context