Patch for IQKeyboardManager issue.

This commit is contained in:
Rossen Hristov
2015-11-05 14:46:35 +02:00
parent ca729e4ce0
commit dec5d971f3
3 changed files with 23 additions and 8 deletions

1
ui/core/view.d.ts vendored
View File

@ -502,6 +502,7 @@ declare module "ui/core/view" {
_goToVisualState(state: string); _goToVisualState(state: string);
_nativeView: any; _nativeView: any;
_isVisible: boolean; _isVisible: boolean;
_setNativeViewFrame(nativeView: UIView, frame: CGRect): void;
//@endprivate //@endprivate
} }

View File

@ -232,13 +232,20 @@ export class View extends viewCommon.View {
// //
} }
public _setNativeViewFrame(nativeView: UIView, frame: CGRect) {
if (!CGRectEqualToRect(nativeView.frame, frame)) {
trace.write(this + ", Native setFrame: = " + NSStringFromCGRect(frame), trace.categories.Layout);
nativeView.frame = frame;
var boundsOrigin = nativeView.bounds.origin;
nativeView.bounds = CGRectMake(boundsOrigin.x, boundsOrigin.y, frame.size.width, frame.size.height);
}
}
public layoutNativeView(left: number, top: number, right: number, bottom: number): void { public layoutNativeView(left: number, top: number, right: number, bottom: number): void {
if (!this._nativeView) { if (!this._nativeView) {
return; return;
} }
var frame = CGRectMake(left, top, right - left, bottom - top);
// This is done because when rotated in iOS7 there is rotation applied on the first subview on the Window which is our frame.nativeView.view. // This is done because when rotated in iOS7 there is rotation applied on the first subview on the Window which is our frame.nativeView.view.
// If we set it it should be transformed so it is correct. // If we set it it should be transformed so it is correct.
// When in landscape in iOS 7 there is transformation on the first subview of the window so we set frame to its subview. // When in landscape in iOS 7 there is transformation on the first subview of the window so we set frame to its subview.
@ -252,12 +259,8 @@ export class View extends viewCommon.View {
nativeView = this._nativeView; nativeView = this._nativeView;
} }
if (!CGRectEqualToRect(nativeView.frame, frame)) { var frame = CGRectMake(left, top, right - left, bottom - top);
trace.write(this + ", Native setFrame: = " + NSStringFromCGRect(frame), trace.categories.Layout); this._setNativeViewFrame(nativeView, frame);
nativeView.frame = frame;
var boundsOrigin = nativeView.bounds.origin;
nativeView.bounds = CGRectMake(boundsOrigin.x, boundsOrigin.y, frame.size.width, frame.size.height);
}
} }
public _updateLayout() { public _updateLayout() {

View File

@ -233,6 +233,17 @@ export class Frame extends frameCommon.Frame {
var navigationBar = this._ios.controller.navigationBar; var navigationBar = this._ios.controller.navigationBar;
return (navigationBar && !this._ios.controller.navigationBarHidden) ? navigationBar.frame.size.height : 0; return (navigationBar && !this._ios.controller.navigationBarHidden) ? navigationBar.frame.size.height : 0;
} }
public _setNativeViewFrame(nativeView: UIView, frame: CGRect) {
// HACK: The plugin https://github.com/hackiftekhar/IQKeyboardManager offsets our Frame's 'nativeView.frame.origin.y'
// to a negative value so the currently focused TextField/TextView is always on the screen while the soft keyboard is showing.
// Our Frame always wants to have an origin of {0, 0}, so if someone else has been playing with origin.x or origin.y do not bring it back to {0, 0}.
if (nativeView.frame.size.width === frame.size.width && nativeView.frame.size.height === frame.size.height) {
return;
}
super._setNativeViewFrame(nativeView, frame);
}
} }
class UINavigationControllerImpl extends UINavigationController implements UINavigationControllerDelegate { class UINavigationControllerImpl extends UINavigationController implements UINavigationControllerDelegate {