Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions WYPopoverController/WYPopoverController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,10 @@ - (void)presentPopoverFromRect:(CGRect)aRect
completion:nil];
}

- (UIWindow *)getWindow {
return _inView.window == nil ? [[[UIApplication sharedApplication] delegate] window] : _inView.window;
}

- (void)presentPopoverFromRect:(CGRect)aRect
inView:(UIView *)aView
permittedArrowDirections:(WYPopoverArrowDirection)aArrowDirections
Expand All @@ -1786,7 +1790,7 @@ - (void)presentPopoverFromRect:(CGRect)aRect
CGSize contentViewSize = self.popoverContentSize;

if (_overlayView == nil) {
_overlayView = [[WYPopoverOverlayView alloc] initWithFrame:_inView.window.bounds];
_overlayView = [[WYPopoverOverlayView alloc] initWithFrame:[self getWindow].bounds];
_overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_overlayView.autoresizesSubviews = NO;
_overlayView.delegate = self;
Expand All @@ -1808,8 +1812,8 @@ - (void)presentPopoverFromRect:(CGRect)aRect
[_backgroundView addGestureRecognizer:tap];
}

[_inView.window addSubview:_backgroundView];
[_inView.window insertSubview:_overlayView belowSubview:_backgroundView];
[[self getWindow] addSubview:_backgroundView];
[[self getWindow] insertSubview:_overlayView belowSubview:_backgroundView];
}

[self updateThemeUI];
Expand Down Expand Up @@ -1842,8 +1846,8 @@ - (void)presentPopoverFromRect:(CGRect)aRect

void (^adjustTintDimmed)() = ^() {
#ifdef WY_BASE_SDK_7_ENABLED
if (_backgroundView.dimsBackgroundViewsTintColor && [_inView.window respondsToSelector:@selector(setTintAdjustmentMode:)]) {
for (UIView *subview in _inView.window.subviews) {
if (_backgroundView.dimsBackgroundViewsTintColor && [[self getWindow] respondsToSelector:@selector(setTintAdjustmentMode:)]) {
for (UIView *subview in [self getWindow].subviews) {
if (subview != _backgroundView) {
[subview setTintAdjustmentMode:UIViewTintAdjustmentModeDimmed];
}
Expand Down Expand Up @@ -2087,7 +2091,7 @@ - (void)positionPopover:(BOOL)aAnimated {

WYPopoverArrowDirection arrowDirection = _permittedArrowDirections;

_overlayView.bounds = _inView.window.bounds;
_overlayView.bounds = [self getWindow].bounds;
_backgroundView.transform = CGAffineTransformIdentity;

viewFrame = [_inView convertRect:_rect toView:nil];
Expand Down Expand Up @@ -2402,8 +2406,8 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated

void (^adjustTintAutomatic)() = ^() {
#ifdef WY_BASE_SDK_7_ENABLED
if ([_inView.window respondsToSelector:@selector(setTintAdjustmentMode:)]) {
for (UIView *subview in _inView.window.subviews) {
if ([[self getWindow] respondsToSelector:@selector(setTintAdjustmentMode:)]) {
for (UIView *subview in [self getWindow].subviews) {
if (subview != _backgroundView) {
[subview setTintAdjustmentMode:UIViewTintAdjustmentModeAutomatic];
}
Expand Down