robmn
April 10, 2019, 7:46pm
2
At 4:18 when you enter ( after present , I don’t get the same suggestions.
drw_sh
April 28, 2019, 1:22pm
3
Hello!
I have a common problem (google didn’t help me alas):
Warning: Attempt to present <UIAlertController: …> on <BullsEyes.ViewController: …> whose view is not in the window hierarchy!
What is strange is that when I did the “knock-knock” button, it worked but not “hit me!”.
Can you help me?
@robmn Do you still have issues with this?
@drw_sh Please check out this post when you get a chance:
opened 05:06PM - 31 Jan 16 UTC
closed 10:38PM - 02 Feb 16 UTC
help wanted
question
Hi all,
I have started a project based on the storyboard SideNavigationViewCont… roller project.
I want to add a login page on project startup using the presentViewController function.
My AppDelegate.swift has the application funct:
```
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Get view controllers from storyboard
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainViewController = storyboard.instantiateViewControllerWithIdentifier("MainViewController") as! MainViewController
let sideViewController = storyboard.instantiateViewControllerWithIdentifier("SideViewController") as! SideViewController
let loginViewController = storyboard.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
let sideNavigationViewController = SideNavigationViewController(mainViewController: mainViewController, leftViewController: sideViewController)
sideNavigationViewController.presentViewController(loginViewController, animated: true, completion: nil)
// Configure the window with the SideNavigationViewController as the root view controller
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.rootViewController = sideNavigationViewController
window?.makeKeyAndVisible()
return true
}
```
When running the application, the login view does not show up and the debug output is:
```
SideNavigationViewController[14922:1560186] Warning: Attempt to present <SideNavigationViewController.LoginViewController: 0x7fa909d91470> on <SideNavigationViewController.MainViewController: 0x7fa909c86b20> whose view is not in the window hierarchy!
```
Any help will be very much appreciated.
Disclamer: I'm a novice swift developer.
I hope it helps!
drw_sh
April 30, 2019, 1:23pm
6
Sorry, no :c
Here’s the code:
@IBAction func showAlert() {
let message = "The value of the slider is now: \(currentValue)"
let alert = UIAlertController(title: "Hello, World!", message: message, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
}
I’ve tried to change the order of the “present”-statement but alas…
For me the issue was that I’ve left print("Hello!")
from previous part. I have no idea why, but deleting it fixed everything.
1 Like