I am writing a UIControl. I need to display a popover when the user touches an area of the control. But of course the usual code:
[self presentViewController:self.popover animated:YES completion:nil];
does not work because we are in a UIControl, not in a UIViewController. How can I display a popover from a UIControl?
You should use rootViewController
to present it.
Use UIApplication.sharedApplication.delegate.window.rootViewController
instead of self
[UIApplication.sharedApplication.delegate.window.rootViewController presentViewController:self.popover animated:YES completion:nil];