On iPhone and iPod touch, the presented view is always full screen. On iPad, the presentation depends on the value in the modalPresentationStyle property. This method sets the presentedViewController property to the specified view controller, resizes that view controller’s view and then adds the view to the view hierarchy.
Questions tagged [presentviewcontroller]
527 questions
102
votes
5 answers
iOS 10 error [access] when using UIImagePickerController
I am using XCode 8 and testing with iOS 10.2 Beta.
I have added the Photos, PhotosUI and MobileCoreServices frameworks to project.
Very simple code:
#import
#import
#import…

sudoExclaimationExclaimation
- 7,992
- 10
- 47
- 105
90
votes
17 answers
Warning: Attempt to present * on * whose view is not in the window hierarchy - swift
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() {
…

Nils Wasell
- 987
- 1
- 8
- 10
83
votes
14 answers
Swift presentViewController
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…

Z-Tech
- 4,360
- 4
- 17
- 10
82
votes
6 answers
modal View controllers - how to display and dismiss
I'm breaking my head for the last one week on how to solve the issue with showing and dismissing multiple view controllers. I have created a sample project and pasting the code directly from the project. I have 3 view controllers with their…

Hema
- 947
- 1
- 8
- 13
72
votes
8 answers
How to call a View Controller programmatically?
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…

John Farkerson
- 2,543
- 2
- 23
- 33
39
votes
4 answers
iOS: Warning "attempt to present ViewController whose view is not in the window hierarchy"
I am getting following warning when I try to present a ActivityController on navigation controller,
Attempt to present on whose view is not in the window hierarchy!
I have…

iOSNoob
- 1,420
- 2
- 16
- 30
38
votes
9 answers
iOS: present view controller programmatically
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…

Salieh
- 693
- 2
- 7
- 12
37
votes
2 answers
Present a view controller, dismiss it and present a different one in Swift
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…

ravelinx
- 1,557
- 4
- 18
- 26
28
votes
11 answers
Push View from Presented View Controller in iOS
In Short :
How can I PushViewController from Presented ViewController ?
In Brief :
I have MainViewController, In which I have one button on click of button, I am presenting a view called LoginViewController.
On this page (LoginViewController), I…

Meet Doshi
- 4,241
- 10
- 40
- 81
25
votes
5 answers
presentViewController in AppDelegate with delay in iOS8
So I had a full working solution in iOS7 that displays a LoginViewController via presentViewController in the AppDelegate's didFinishLaunching.
Basically I am doing something like this:
UIViewController *backgroundViewController =…

Tiago Almeida
- 14,081
- 3
- 67
- 82
23
votes
5 answers
Using presentViewController from UIView
I am creating a title bar for my iOS application and I am making this inside a UIView. The only issue I am having is with the "home button". When the home button is pressed, it needs to go to the home page, which is ViewController.
However, it…

Ashish Agarwal
- 14,555
- 31
- 86
- 125
22
votes
4 answers
"viewWillTransitionToSize:" not called in iOS 9 when the view controller is presented modally
I present a view controller from another one:
- (void)showModalView
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MySecViewController *mySecViewController = [storyboard…

AppsDev
- 12,319
- 23
- 93
- 186
21
votes
5 answers
Incorrect frame when dismissing modally presented view controller
I am presenting a UIViewController using a custom transition and a custom UIPresentationController. The view controller's view does not cover the entire screen, so the presenting view controller is still visible.
Next, I present an instance of…

caryot
- 251
- 2
- 5
17
votes
5 answers
dismiss current view controller AFTER presenting new view controller - swift
I'm trying to dismiss a VC and present a new VC. but I don't want old VC to exist anymore. I use the code below to dismiss current VC and present new one. but this way, there's a time interval between dismiss and present. I don't want the user to…

Hos Ap
- 1,168
- 2
- 11
- 24
15
votes
4 answers
Presenting a View Controller with a button in a UITableViewCell programmatically (Swift)
I am trying to make it where when a user clicks on a table view cell in my table view it takes them to a new view controller. More specifically, when a user clicks on a persons username it should take them to that users profile. the username being…

Ronald Jones
- 201
- 1
- 2
- 4