From 23dc84d84b864ab3946585988ca53a24abae59a5 Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Wed, 6 Feb 2019 14:04:27 +0200 Subject: [PATCH] fix(ios): textview content clipped on every other newline (#6864) --- tns-core-modules/ui/text-view/text-view.ios.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tns-core-modules/ui/text-view/text-view.ios.ts b/tns-core-modules/ui/text-view/text-view.ios.ts index 31dcb4176..687532ca7 100644 --- a/tns-core-modules/ui/text-view/text-view.ios.ts +++ b/tns-core-modules/ui/text-view/text-view.ios.ts @@ -95,6 +95,16 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate { } } +class NoScrollAnimationUITextView extends UITextView { + // see https://github.com/NativeScript/NativeScript/issues/6863 + // UITextView internally scrolls the text you are currently typing to visible when newline character + // is typed but the scroll animation is not needed because at the same time we are expanding + // the textview (setting its frame) + public setContentOffsetAnimated(contentOffset: CGPoint, animated: boolean): void { + super.setContentOffsetAnimated(contentOffset, false); + } +} + @CSSType("TextView") export class TextView extends EditableTextBase implements TextViewDefinition { nativeViewProtected: UITextView; @@ -103,7 +113,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition { public _isEditing: boolean; createNativeView() { - const textView = UITextView.new(); + const textView = NoScrollAnimationUITextView.new(); if (!textView.font) { textView.font = UIFont.systemFontOfSize(12); }