UITextview is getting randomly clipped when using Autolayout and or preferredFontForTextStyle

get text from uitextfield swift 4
uitableview automaticdimension uitextview
uitableviewcell uitextview auto height
uitextview height based on text swift
get text from uitableviewcell
swift uitableviewcell autolayout
get cell from indexpath swift
custom uitableviewcell for text input in swift

Autolayout will randomly clip the text in my UITextView. It changes the size of the UITextContainerView when you rotate back and forth from landscape to portrait. It will work correctly several times but will randomly change the container and clip the static text.

If I disable Autolayout then the issue goes away. It also seems to go away if I eliminate the preferredFontForTextStyle code and keep the Autolayout.

The thing is I wanted to allow the user to set the text size and be able to use auto layout. The text is all static so this should be a simple thing.

Has anyone seen this? Is this a bug or have to do something incorrectly?

I have reduced the code to as small as I could in order to try and isolate the problem.

Here is the code

//  BugTest_ViewController.h
//
//
//
//

#import <UIKit/UIKit.h>

@interface BugTest_ViewController : UIViewController



@property (weak, nonatomic) IBOutlet UIImageView *image1;

@property (weak, nonatomic) IBOutlet UITextView *text1;



@end

The solution from this question helps me. I write something like this:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
    _textView.scrollEnabled = NO;
    [coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
        _textView.scrollEnabled = YES;
    }];
}

ios, The solution from this question helps me. I write something like this: - (void)​viewWillTransitionToSize:(CGSize)size  iOS 6 added multiple text-style capability to UITextView.To use multiple styles, application developers must use the AttributedText property. The Font, TextColor, and TextAlignment properties apply to all the text in the UITextView.

Looks like this happens because of call setContentOffset: which confuses scrollView in UITextView. My solution for scroll down of UITextView:

NSRange range = NSMakeRange(self.outputTextView.text.length - 1, 1);
[self.outputTextView scrollRangeToVisible:range];
self.outputTextView.scrollEnabled = NO;
self.outputTextView.scrollEnabled = YES;

This re enabling of scroll fixes it.

Embedding UITextView inside UITableViewCell, After all it just a UITextView in a UITableViewCell, right? With reload data you get to make only one change to the text view because As you can see, the row indeed changes height but UITextView is clipped, also we don't have the weird iOS · Uitableview · Uitableviewcell · Uitextview · Autolayout  Imho this is the definitive answer for all of the typical UITextView-scrolling / keyboard related issues in iOS 7. Its clean, its easy to read, easy to use, easy to maintain and can easily be reused. The basic trick: Simply change the size of the UITextView, not the content inset! Here's a hands-on example.

The reason seems to be that a transformation applied to a UITextView can sometimes corrupt the view's dynamic layout. A screen rotation effectively applies rotation and translation transformations to the views during the transition.

The same issue happens when CGAffineTransform is applied to a UITextView. Here is a visual example where the _UITextContainerView (blue frame) is smaller than the UITextView (green background) after a CGAffineTransform, causing the text to be appear cropped.

One solution that worked in this case was to set the content inset after the transformation has finished:

textView.contentInset = .zero
view.layoutIfNeeded()

UITextView Class (UIKit), PreferredFontForTextStyle(UIFontTextStyle. Gets or sets whether the UITextView automatically updates the font if the device's content-size category changes. AlignmentRectInsets. Adjustments to the Frame for use with Auto Layout. Randomly changes the Frame within an ambiguous set of Auto Layout constraints. Why is boundingRectWithSize wrong when using UIFont preferredFontForTextStyle? ios8,nsstring,uilabel,uifont. A label adds a little margin round the outside of the text, and you have not allowed for that. If, instead, you use a custom UIView exactly the size of the string rect, you will see that the text fits perfectly: Here's the code I used.

Use

[text1 setNeedsLayout];
[text1 layoutIfNeeded]; 

when you change the frame of the text view. That should fix the problem.

AutoLayout by johnlui, Adopting dynamic type is as simple as using the preferred font for a given text style. preferredFontForTextStyle(UIFontTextStyleHeadline) subhead.font = UIFont. Doing this for every view controller quickly becomes tedious… iOS 10 introduces a new property on UILabel , UITextField and UITextView . A label adds a little margin round the outside of the text, and you have not allowed for that. If, instead, you use a custom UIView exactly the size of the string rect, you will see that the text fits perfectly: Here's the code I used.

Auto Adjusting Fonts for Dynamic Type, Hello, I'm facing problem with UITextView, basically it cuts off ending of the text. Here's constraints that I'm setting for TextView : Both, gets the same result. Thanks for any help,. Regards. Tags: none (add) autolayout. iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06) 1. More iOS UI Considerations Lecture 06:Attributed Strings and Auto Layout Jonathan R. Engelsma, Ph.D. 2. TOPICS • Attributed Strings • Autorotation • Auto Layout 3.

UITextView cuts off text in autolayout UITableV |Apple Developer , ios,iphone,ipad,ios8,testflight I need to submit my binary files over the air without pushing app to app-store. one solution is using enterprise program, Test-Flight App Beta Testing we can send binary files to external users to limit of 1000. My Questions is : will apple take beta review (following apple guidelines) of

Why is boundingRectWithSize wrong when using UIFont preferredFontForTextStyle? ios8,nsstring,uilabel,uifont. A label adds a little margin round the outside of the text, and you have not allowed for that. If, instead, you use a custom UIView exactly the size of the string rect, you will see that the text fits perfectly: Here's the code I used.

Comments
  • Check your constraints of text view.
  • I did. There were no conflicts or warnings.
  • There a 4 constraints present. Leading Space to : Superview = -7.0 Bottom Space to: Superview = 0 Align Center x to: Image 1 Top space to :Image 1 = default.
  • Re-Tested with the latest Xcode release (Version 7.2.1 (7C1002)) and the problem persists. No response from Apple either.