In my app, I am using a navigation controller. Later on in some view I am using presentViewController
for showing a zoomed image.
Also I am not using a Storyboard or nib.
I am getting this error in iOS 7 only. It works fine in iOS 6 and earlier:
Presenting view controllers on detached view controllers is discouraged
Yes, I also faced the same warning message while displaying an Alert controller which was in another view. Later on I avoided this by presenting the alert controller from the parent view controller as below:
In Swift 4.1 and Xcode 9.4.1
The solution is
If write like this i'm getting same error
I'm getting same error
Complete solution is
One of the solution to this is if you have childviewcontroller So you simply presentviewcontroller on its parent by given
And for dismiss use the same dismissview controller.
This is perfect solution works for me.
Try this code
It depends if you want to show your alert or something similar in anywhere of kind UIViewController.
You can use this code example: