SolvedNativeScript Keyboard overlays views on iOS
βοΈAccepted Answer
Ohh, and for the solution above created by @Daxito, then I ended up creating a observer for the height change of the keyboard. It looks like this:
export class KeyboardObserver {
public heightChange$(): Observable<number> {
return Observable.create((observer) => {
const iosObserver = application.ios.addNotificationObserver(UIKeyboardWillChangeFrameNotification, (notification) => {
const height = notification.userInfo.valueForKey(UIKeyboardFrameEndUserInfoKey).CGRectValue.size.height;
observer.next(height);
});
return () => {
application.ios.removeNotificationObserver(iosObserver, UIKeyboardWillChangeFrameNotification);
}
});
}
}
Then I can inject the class in any component and subscribe like this:
this._keyboardObserver.heightChange$().subscribe((height) => {
console.log(height);
});
Other Answers:
@mikkeldamm It was very specific to my needs, because it was a Chat Screen with one single Texbox always at the bottom, so just by listening changes in the height of the keyboard like this :
application.ios.addNotificationObserver(UIKeyboardWillChangeFrameNotification, function (notification) {
let hght = notification.userInfo.valueForKey(UIKeyboardFrameEndUserInfoKey).CGRectValue.size.height;
})
Then I would just add a dummy Stack Panel underneath the textbox and when user started typing then I would set the height of this Stack Panel equals to the Notified Keyboard height thus pushing the TextBox up.... it worked :-)
If you have a "form like" screen, then it gets complicated...
I get an issue when I focus a TextView at the bottom of my app.
When I tap the TextView the Keyboard appears, but on iOS the whole view doesn't shift to top.
As you can see the android has the expected behavior but on iOS the keyboard just overlays the other whole page.
My main-page.xml:
I am using newest tons version and iOS/Android runtimes.