Nativescript IOS: Textview not resizing after Input was cleared - ios

I am trying to create a simple chat in nativescript-angular. On Android everything works fine, however on IOS I have this strange bug, where if the user inputs multiple lines into the textview, the textview does not return to the original state, after the message was sent.
The height of the textview is set to "auto", which is needed to have dynamic sizing for the Textview.
When the user clicks the "send" button, the textview should resize to the original size. However it stays the old height. On Android the TextView resizes perfectly..
This is my TextView:
<TextView #textView row="1" column="0" textWrap="true" lineHeight="4" height="auto"
[(text)]="message" (textChange)="onTextChange($event)" class="text-view" ></TextView>
And in my typescript i just set this.message = ''; which works fine enough on Android.
Any suggestions on how to make the TextView resize on IOS? I tried it with accessing the native element and set the height to auto again:
this.textView.nativeElement.height = "auto";
height is a PercentLength Property, and auto is a valid value, however it has no impact. It works if i set it to an absolute number, but I want to avoid that.
Thanks!

iOS doesn't re-layout upon text change, you may force re-layout with following code.
this.textView.nativeElement.requestLayout();

Related

Text is not appearing when UITextView's content is more?

I don't need to scroll inside a UITextView so disabling a scrolling property of my UITextView.
It means UITextView's height is dynamic base on his content.
When I added more text in UITextView then text is not appearing.
It is working with less content.
As per my observation if height of UITextView exceeds 8100 then it stops rendering but not sure about it.
here is a structure of storyboard.
I understand your problem and please check below sample, i am modify your sample. This is working in my case.
Refer:- Updated Demo

UITextView Scrolls to the right when it gains focus in Swift

Whenever I tap on my UITextView on my testing device, the text is pushed far to the right as demonstrated in the gif below.
I can't see why this behaviour is happening, within my Storyboard I have tried to disable scrolling and have applied constraints to ensure that the width of the UITextView is only ever the width of the device, yet this still happens. The UITextView has not been subclassed or had any additional attributes applied to it via code.
If anybody has had this problem before it would be great to get some insight around how I could remedy it.
EDIT Constraints for the text view.

Text is not fully displayed in UITextView

My UITextView is being very weird.
To explain the problem, the UITextView is placed in an UITableViewCell, and at the first display, the second line is missing :
If I continue scrolling down, and go back to see this UITextView, everything is back to normal:
What is very weird, is that if I set my UITextView as none selectable (what I want in fact), the text is well displayed, but the font is lost :
It seems that I have the same problem described here:
UITextView - setting font not working with iOS 6 on XCode 5
and the fix given (setting the UITextView as Selectable) worked fine for the font. But this problem with the cropped text makes this solution inadequate.
The UITextView has a red background color to be sure that the size is ok.
Everything is done in a Storyboard, but I also tried to set the font manually, the problem is still there.
Have you any hint of what could be wrong?
You can use AutoLayout to adjust the UITextView size inside the cell or you can use
[cell.textView sizeToFit];
I recommend using AutoLayout as it shouldn't harm the performance so much.

NSTextView stops being able to scroll once new text is set

I have a TextView made in the Interface Builder;
It scrolls fine with its default text, but as soon as I programatically set the text to something else, it no longer scrolls.
I do not disable scrolling, and I have tried enabling scrolling (setScrollEnabled:YES), and user interaction (setUserInteractionEnabled:YES) both of which make no difference.
The things that I have found:
It scrolls with the default text showing
It doesn't seem to matter what text I set in it, it just stops scrolling as soon as it is set. I'm doing it programatically like this:
self.myTextView.text = #"any text"; (or [self.myTextView setText:#"any text"]; has the same effect.)
I have two other Textfield in the same View, one of which is using the View Controller as its delegate. The TextField in question is not using the View Controller as its delegate. None of the delegate methods set anything to do with scrolling.
Both of the other TextViews have their scrolling capability set to defaults. If I change the one that doesn't need it to no scrolling, it makes no difference to the problem.
The one that has the View Controller as its delegate continues to scroll after I edit it (non programatically) and this one continues to be able to scroll once the one in question freezes.
If I delete these two other TextFields, then the one in question works as expected, i.e. it scrolls after adding text.
Any thoughts?
Thanks.
Make sure your new text is long enough to be able to get scroll.
if text is just one line it wont scroll but if its larger then text area size then it will scroll its by default settings

UITextview not getting completely filled with the text in IPhone

In my app, I have a UITextView. When I key in data in the UITextView, the words are not getting completely filled in the UITextview. There is a boundary within the UITextView and the words scroll up as I key in the words. Is there a setting which I am missing in UITextView. Please let me know. Please find the screenshot below
You can set a frame and a contentSize as it inherits from the UIScrollView to make it bigger. I do not have access to IDE right now but something like this should work:
myTextView.frame = CGRectMake(10,10,300,300);//example values
myTextView.contentSize = CGSizeMake(300,300);//example values
but sooner or later you want be able to see the whole text on the screen and you will need to scroll anyway.
You can also change this values while user is typing by using some delegate methods

Resources