Closed rogomantik closed 7 years ago
Hi @rogomantik Sorry for the delayed answer.
I ended up using the following piece of code as well:
guard let rootView = UIApplication.shared.keyWindow else { return }
So maybe it's the best to use for consistency and reliability?
You are welcome, I did somenting similar
guard let rootView = UIApplication.shared.keyWindow ?? UIApplication.shared.windows.first else { return }
Probably not necessary
@jimmaye I did some test in an app that uses the navigationbar and navigationcontroller without changing the standard behavior and calling popover.show(containerView, fromView: sender) //containerView is a custom view //sender is an UIButton inside a tableview row
using and printing the values
guard let rootView = UIApplication.shared.windows.last //does not shows Optional(<UIWindow: 0x7ff1fa5129c0; frame = (0 0; 375 667); hidden = YES; gestureRecognizers = <NSArray: 0x608000245c70>; layer = <UIWindowLayer: 0x60800003c320>>)
guard let rootView = UIApplication.shared.windows.first //shows Optional(<UIWindow: 0x7f85c5616020; frame = (0 0; 375 667); gestureRecognizers = <NSArray: 0x6100000544c0>; layer = <UIWindowLayer: 0x61000002b040>>)
guard let rootView = UIApplication.shared.keyWindow //shows Optional(<UIWindow: 0x7fa28550f1f0; frame = (0 0; 375 667); gestureRecognizers = <NSArray: 0x610000051100>; layer = <UIWindowLayer: 0x61000003a560>>)
maybe hidden = YES does not allow show the popover? waiting for a opinion and a solution I replaced guard let rootView = UIApplication.shared.windows.last with guard let rootView = UIApplication.shared.windows.first