I create a demo for checking UITextView scrollEnabled
. It only contains 1 UITextView
and 2 button enable and disable scroll
I test on simulator and device iOS 8, if I click the disable scroll button, the UITextView
will disable scroll correctly, but after that I click on enable scroll, the UITextView
won't enable scroll
However, I test on device iOS9, the enable and disable scroll work well.
#import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UITextView *myTextView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; } - (IBAction)enableScrollButtonPressed:(id)sender{ self.myTextView.scrollEnabled = YES; } - (IBAction)disableScrollButtonPressed:(id)sender{ self.myTextView.scrollEnabled = NO; } @end
Any idea to fix this problem? If someone don't understand my explain please check my demo project
Any help or suggestion would be great appreciated
The problem is that in iOS 8, contentSize is not adjusted correctly when scrollEnabled is changed. A small adjustment to your enableScrollButtonPressed method will successfully work around the problem.
-(IBAction)enableScrollButtonPressed:(id)sender { self.myTextView.scrollEnabled = YES; self.myTextView.contentSize = [self.myTextView sizeThatFits:self.myTextView.frame.size]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With