Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): statusbar ui issue fixed #11458

Merged
merged 4 commits into from
Feb 5, 2020
Merged
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions iphone/Classes/TiUIiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ - (void)setStatusBarBackgroundColor:(id)value
}
view.frame = frame;
view.backgroundColor = [[TiUtils colorValue:value] _color];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeKey:) name:UIWindowDidBecomeKeyNotification object:nil];
#endif
} else {
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
Expand Down Expand Up @@ -206,6 +207,8 @@ - (NSNumber *)PREVIEW_ACTION_STYLE_SELECTED

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];

[super dealloc];
}

Expand Down Expand Up @@ -258,6 +261,20 @@ - (void)didReceiveMemoryWarning:(NSNotification *)notification
[super didReceiveMemoryWarning:notification];
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
Copy link
Contributor

Choose a reason for hiding this comment

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

You wrap the method inside this #if guard, but register for the notification on all SDK versions. Could this lead to a crash when building with SDK < 13.0?

Copy link
Contributor Author

@vijaysingh-axway vijaysingh-axway Jan 31, 2020

Choose a reason for hiding this comment

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

That code snippet is also inside #if guard . See complete code-
#if IS_SDK_IOS_13 UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow; CGRect frame = keyWindow.windowScene.statusBarManager.statusBarFrame; UIView *view = [keyWindow viewWithTag:TI_STATUSBAR_TAG]; if (!view) { view = [[UIView alloc] initWithFrame:frame]; view.tag = TI_STATUSBAR_TAG; [keyWindow addSubview:view]; } view.frame = frame; view.backgroundColor = [[TiUtils colorValue:value] _color]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeKey:) name:UIWindowDidBecomeKeyNotification object:nil]; #endif

Replaced above #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 with #if IS_SDK_IOS_13 to be more consistent with code. Though both are same.

Copy link
Contributor

Choose a reason for hiding this comment

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

Duh, i totally missed that since it wasn't showing in the diff. Thanks for updating the constant though, consistency is always good!

- (void)windowDidBecomeKey:(NSNotification *)notification
{
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
CGRect frame = keyWindow.windowScene.statusBarManager.statusBarFrame;
UIView *view = [keyWindow viewWithTag:TI_STATUSBAR_TAG];
if (view) {
view.frame = frame;
}
}
}
#endif

#ifdef USE_TI_UIIOSALERTDIALOGSTYLE
- (TIUIiOSAlertDialogStyleProxy *)AlertDialogStyle
{
Expand Down