@@ -55,6 +55,8 @@ - (void)pluginInitialize
55
55
{
56
56
NSDictionary *settings = self.commandDelegate .settings ;
57
57
58
+ [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (statusBarDidChangeFrame: ) name: UIApplicationDidChangeStatusBarFrameNotification object: nil ];
59
+
58
60
self.keyboardResizes = ResizeNative;
59
61
BOOL doesResize = [settings cordovaBoolSettingForKey: @" KeyboardResize" defaultValue: YES ];
60
62
if (!doesResize) {
@@ -95,6 +97,11 @@ - (void)pluginInitialize
95
97
}
96
98
}
97
99
100
+ -(void )statusBarDidChangeFrame : (NSNotification *)notification
101
+ {
102
+ [self _updateFrame ];
103
+ }
104
+
98
105
99
106
#pragma mark Keyboard events
100
107
@@ -174,26 +181,35 @@ - (void)setPaddingBottom:(int)paddingBottom delay:(NSTimeInterval)delay
174
181
175
182
- (void )_updateFrame
176
183
{
184
+ CGSize statusBarSize = [[UIApplication sharedApplication ] statusBarFrame ].size ;
185
+ int statusBarHeight = MIN (statusBarSize.width , statusBarSize.height );
186
+
187
+ int _paddingBottom = (int )self.paddingBottom ;
188
+
189
+ if (statusBarHeight == 40 ) {
190
+ _paddingBottom = _paddingBottom + 20 ;
191
+ }
177
192
NSLog (@" CDVIonicKeyboard: updating frame" );
178
193
CGRect f = [[UIScreen mainScreen ] bounds ];
194
+ CGRect wf = self.webView .frame ;
179
195
switch (self.keyboardResizes ) {
180
196
case ResizeBody:
181
197
{
182
198
NSString *js = [NSString stringWithFormat: @" Keyboard.fireOnResize(%d , %d , document.body);" ,
183
- ( int ) self .paddingBottom , (int )f.size.height];
199
+ _paddingBottom , (int )f.size.height];
184
200
[self .commandDelegate evalJs: js];
185
201
break ;
186
202
}
187
203
case ResizeIonic:
188
204
{
189
205
NSString *js = [NSString stringWithFormat: @" Keyboard.fireOnResize(%d , %d , document.querySelector('ion-app'));" ,
190
- ( int ) self .paddingBottom , (int )f.size.height];
206
+ _paddingBottom , (int )f.size.height];
191
207
[self .commandDelegate evalJs: js];
192
208
break ;
193
209
}
194
210
case ResizeNative:
195
211
{
196
- [self .webView setFrame: CGRectMake (f .origin.x, f .origin.y, f.size.width, f.size.height - self .paddingBottom)];
212
+ [self .webView setFrame: CGRectMake (wf .origin.x, wf .origin.y, f.size.width - wf.origin.x , f.size.height - wf.origin.y - self .paddingBottom)];
197
213
break ;
198
214
}
199
215
default :
0 commit comments