Auto-layout will randomly copy text into my UITextView. It resizes the UITextContainerView as you rotate back and forth from landscape to portrait. It will work correctly several times, but will randomly modify the container and remove static text.
If I turn off auto-detection, the problem will disappear. These are also stitches to go away if I excluded the preferredFontForTextStyle code and saved Autolayout.
The fact is that I wanted to allow the user to set the size of the text and be able to use the automatic layout. The text is all static, so it should be simple.
Has anyone seen this? Is this a mistake or is something wrong done?
I reduced the code to the extent I could in order to try to 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
// BugTest_ViewController.m // // // // #import "BugTest_ViewController.h" @interface BugTest_ViewController () @end @implementation BugTest_ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } -(void)viewWillAppear:(BOOL)animated { self.text1.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody]; [self.text1 setContentOffset:CGPointZero animated:YES]; }
Here is the container when the view looks as it should A good container
Here is the container when the object is cropped. Bad container clipping my text
source share