0
UIApplication.sharedApplication.statusBarHidden=YES;

is deprecated in iOS 13. The compiler says to 'use the statusBarManager property of the window scene instead'.

How/Where do you get the handle to statusBarManager? It's not in UIApplication.sharedApplication.windows.

TomV
  • 1,157
  • 1
  • 13
  • 25
  • Are you using an older version of swift? `UIApplication.sharedApplication` was changed to `UIApplication.shared` – Scriptable Mar 30 '20 at 13:32
  • Thanks but using objective-c as per the tags underneath the question. – TomV Mar 30 '20 at 13:33
  • ah gotcha. didn't notice that. i'll remove my answer. – Scriptable Mar 30 '20 at 13:33
  • 1
    There's a pointer to your solution right in the error message: "... of the window scene instead" – Gereon Mar 30 '20 at 15:32
  • `UIViewControllers`'s `prefersStatusBarHidden` isn't deprecated – Cy-4AH Mar 30 '20 at 15:32
  • #Gareon - I appreciate the pointer to the error msg. I have done lots of research around this and at a loss. Hence me asking a question on Stackoverflow to get further help. – TomV Mar 30 '20 at 17:13
  • #Cy-4AH - Thanks. But I wish to set the status bar as hidden. prefersStatusBarHidden is read onle. – TomV Mar 30 '20 at 17:15
  • You can write `@property (nonatomic) BOOL prefersStatusBarHidden` in your's subclasses – Cy-4AH Mar 31 '20 at 14:35
  • Gareon is trying to say, that `UIWindow` and `UIWindowScene` is two different things. – Cy-4AH Mar 31 '20 at 14:37
  • #Cy-4AH Thanks but a warning appears: Auto property synthesis will not synthesize property 'prefersStatusBarHidden' because it is 'readwrite' but it will be synthesized 'readonly' via another property – TomV Mar 31 '20 at 18:26
  • Just write `@synthesize prefersStatusBarHidden;` in implementation – Cy-4AH Apr 02 '20 at 09:29
  • Thanks but don't understand how just creating a variable and making it writable actually makes any changes. Found an answer as below, so many thanks for your efforts. – TomV Apr 02 '20 at 13:52
  • You become able to use view controller's `prefersStatusBarHidden` instead of window's `sharedApplication` – Cy-4AH Apr 04 '20 at 08:16
  • Does this answer your question? [Hide Status Bar from iPhone application](https://stackoverflow.com/questions/19018391/hide-status-bar-from-iphone-application) – Cy-4AH Apr 04 '20 at 08:24
  • No. The status bar was still there. I found the answer eventually as below. Thanks again. – TomV Apr 06 '20 at 09:25

1 Answers1

0

Remove all instances which is deprecated in iOS13:

UIApplication.sharedApplication.statusBarHidden=YES;

Instead add this to the plist file:

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIStatusBarHidden</key>
<true/>
TomV
  • 1,157
  • 1
  • 13
  • 25