Autolayout将随机剪辑我的UITextView中的文本.当您从横向到纵向来回旋转时,它会更改UITextContainerView的大小.它会正常工作几次,但会随机更改容器并剪切静态文本.
如果我禁用Autolayout,那么问题就会消失.如果我删除preferredFontForTextStyle代码并保持Autolayout,它似乎也会消失.
问题是我想让用户设置文本大小并能够使用自动布局.文本都是静态的,所以这应该是一件简单的事情.
有没有人见过这个?这是一个错误还是必须做错误的事情?
为了尝试找出问题,我已经将代码缩小到尽可能小.
这是代码
// BugTest_ViewController.h
//
//
//
//
#import <UIKit/UIKit.h>
@interface BugTest_ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIImageView *image1;
@property (weak, nonatomic) IBOutlet UITextView *text1;
@endRun Code Online (Sandbox Code Playgroud)
// 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];
}Run Code Online (Sandbox Code Playgroud)
当视图看起来应该是Good Container时,这是 容器
这是查看视图时的容器. 坏容器剪辑我的文本