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
// 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 Good Container
Here is the container when the view is being clipped. Bad Container clipping my text