digibusiness opened a new issue #177: Wrong status bar height after input:file 
"Take Photo" (iOS 13 only)
URL: https://github.com/apache/cordova-plugin-statusbar/issues/177
 
 
   # Bug Report
   With StatusBarOverlaysWebView=false, if I choose "Take Photo" from an 
`<input type="file" accept="image/*" />`, when the app goes back to the webview 
(clicking Cancel is enough) the status bar height is set to 0.
   After that, the status bar aspect is the same as if it was set to 
StatusBarOverlaysWebView=true.
   In iOS 12 the height is set properly.
   
   ## Problem
   After a photo is taken (or "Cancel" is clicked) `cordovaViewWillAppear` is 
invoked (file CDVStatusBar.m), then `[self resizeWebView];` is called.
   Inside `resizeWebView`, `[UIApplication sharedApplication].statusBarFrame` 
returns a 0x0 CGRect.
   Consequently, the height of the status bar is set to 0.
   
   ### What is expected to happen?
   The status bar height should be set to the correct height.
   
   ### What does actually happen?
   The status bar height is set to 0, so the result is the same as 
StatusBarOverlaysWebView=true.
   
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   To fix this problem, I have changed the cordovaViewWillAppear method with 
the same fix applied to statusBarDidChangeFrame.
   I don't know if this has any side effects...
   
   **Before**
   ```
   -(void)cordovaViewWillAppear:(NSNotification*)notification
   {
       [self resizeWebView];
   }
   ```
   
   **After**
   ```
   -(void)cordovaViewWillAppear:(NSNotification*)notification
   {
       //Fix
       //[self resizeWebView];
       //add a small delay ( 0.1 seconds ) or statusbar size will be wrong
       __weak CDVStatusBar* weakSelf = self;
       dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), 
dispatch_get_main_queue(), ^{
           [weakSelf resizeWebView];
       });
       //End fix
   }
   ```
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   - Create an empty cordova project `cordova create TestApp 
com.cordova.testApp TestApp`
   - Add iOS platform `cordova platform add ios`
   - Add cordova-plugin-statusbar `cordova plugin add cordova-plugin-statusbar`
   - In www/index.html, replace `<body>` with `<body>TEST<input type="file" 
accept="image/*" />`
   - In www/css/index.css remove
   `padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 
env(safe-area-inset-bottom, 0px) env(safe-area-inset-right, 0px)`
   - In config.xml insert:
   `<preference name="StatusBarOverlaysWebView" value="false" />`
   `<preference name="StatusBarBackgroundColor" value="#E4E4E4" />`
   - Run `cordova prepare`
   - From XCode run the app in a physical device (iOS simulator has no camera)
   - Click "Choose File", then "Take Photo", then "OK"
   - Finally click Cancel (or take a photo), now "TEST" is under the status bar
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   iOS 13
   Tested on iPad Pro 9.7 and iPhone X.
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   Cordova CLI 9.0.0
   Cordova iOS platform v5.1.1
   cordova-plugin-statusbar v2.4.2
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to