UITextView Scrolls to the right when it gains focus in Swift - ios

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.

Related

UITextView on Catalyst with Long text, invisible text ranges when scrolling

I have an issue with Catalyst. I'm trying to display a long text in a UITextView, and on iOS everything works well, no issues.
On Mac (with Catalyst) however, when I scroll the textview, some parts disappear. Does anyone have an idea on how to fix this?
I have tried calling setNeedsLayout/Display/layoutIfNeeded on the textview when scrolling but no luck. The only thing that "worked" is to remove the textview from the view hierarchy and readd it to the container view on scroll finished. Still not ideal, as you lose selection when you want to select some text and scroll. (When I save the selection and re-apply it, then the blue highlight is invisible)
Using a UILabel in a scrollview could work, but then you lose all user interactions (no editing/selecting text)
Does anyone have any idea on how to fix this? Or I should just wait for Apple to fix this.
See the video/gif of the original issue:

UITextView inside UIScrollview displays properly, but I cannot get it to respond to text input

I have my text views setup as such, and they display exactly as they should. I am able to scroll properly, however when I click on the text boxes, I get no keyboard and am unable to type. If I make one of the textViews the first responder, I can type, but I cannot get out of it. Tapping on the other textView does nothing, and I cannot edit text or move the cursor. Any help appreciated!
Turns out the scroll view was still having trouble with size ambiguity. I had assumed I could fix that later since it was displaying everything properly, but even when I placed a button inside the view that's inside the scrollview, the button didn't respond to touch either.
After fixing the ambiguity warning, it started responding properly to touch. Not sure why this is the case, but that's how I solved my problem.
I couldn't recreate your issue mine works fine and both respond to touches. Must have been a sizing issue in IB.

Prevent scrollview from autoresizing

Im creating a basic messaging app with the message "bubbles" inside a scroll view. When the user first opens the screen the keyboard is not showing (besides an input box at the bottom), when they press the input box and start typing the keyboard with pop up (using NSNotificationCenter) a function will be called to resize the scrollview so that is no longer behind the keyboard.
That part all works well but when the user sends their message and a new bubble is added to the scrollview. The scrollview will automatically revert back to the size of the screen thus being behind the keyboard.
The scrollview is originally created in storyboard to take up the whole dimensions of the screen. So I suspect the cause of the resizing is due to some kind of message calling autolayout to update the scrollview when a subview is being added to it.
Im looking for a way to prevent the scroll view from reverting back to this autolayout when a subview is added to it, Thank you!
When the keyboard appears, adjust the UIScrollView's size by modifying its constraint's constants.

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

Resources