Skip to content

Commit c10ae16

Browse files
fix issue #50
1 parent ceded0c commit c10ae16

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

WYPopoverController/WYPopoverController.m

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,25 +1401,28 @@ - (UIViewController*)contentViewController
14011401

14021402
- (UIView *)rootView
14031403
{
1404-
UIWindow *result = [[UIApplication sharedApplication] keyWindow];
1404+
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
14051405

1406-
int count = result.subviews.count;
1406+
int count = keyWindow.subviews.count;
1407+
1408+
UIView *result = keyWindow;
14071409

14081410
if (count > 0)
14091411
{
1410-
UIView *view = nil;
1411-
1412-
for (NSUInteger i = count; i <= 0; i--)
1412+
int lastIndex = count - 1;
1413+
1414+
for (NSInteger i = lastIndex; i >= 0; i--)
14131415
{
1414-
view = [result.subviews objectAtIndex:i];
1416+
UIView *view = [keyWindow.subviews objectAtIndex:i];
1417+
1418+
//WY_LOG(@"rootView.subview[%i] = %@", i, view);
14151419

14161420
if (!view.isHidden)
14171421
{
1418-
return view;
1422+
result = view;
1423+
break;
14191424
}
14201425
}
1421-
1422-
// result = [result.subviews lastObject];
14231426
}
14241427

14251428
return result;

0 commit comments

Comments
 (0)