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
8 changes: 6 additions & 2 deletions Source/MMProgressHUDViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ - (void)dealloc {
MMHudLog(@"dealloc");
}

- (UIStatusBarStyle)preferredStatusBarStyle{
- (UIStatusBarStyle)preferredStatusBarStyle
{
if([self.presentingViewController respondsToSelector:@selector(preferredStatusBarStyle)]){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is presentingViewController non-nil for the only view controller in a window?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If presentingViewControlleris nil, a message is sent to nil and the test fails
if([self.presentingViewController respondsToSelector:@selector(preferredStatusBarStyle)]) equals if(nil) and the code below will not be called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the above is true, I was asking because I'm not positive that presentingViewController is ever non-nil. Since this view controller is never really ever presented, and simply used as the root view controller of a window that we control. The only way I could see this working is if the presentedViewController that we are querying is on the key window's root view controller and not our own window.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I did tests with a tab bar controller based application and a navigation controller based application and the behavior is different. With the tab bar based application, the presentingViewController is the controller within the tab bar that presented the HUD. With the navigation controller, presentingViewController is nil.

return [self.presentingViewController preferredStatusBarStyle];
}

return [[UIApplication sharedApplication] statusBarStyle];
}

- (BOOL)prefersStatusBarHidden{
return [[UIApplication sharedApplication] isStatusBarHidden];
}

@end