gpt4 book ai didi

ios - UITextView scrollEnabled = YES 在 iOS8 中设置 scrollEnabled = NO 后不工作

转载 作者:IT王子 更新时间:2023-10-29 08:02:53 26 4
gpt4 key购买 nike

我创建了一个用于检查 UITextView scrollEnabled 的演示。它仅包含 1 个 UITextView 和 2 个按钮启用和禁用滚动

  • 我在模拟器和设备 iOS 8 上进行测试,如果我单击禁用滚动按钮,UITextView 将正确禁用滚动,但在那之后我点击启用滚动,UITextView 不会启用滚动

  • 但是,我在 iOS9 设备上测试,启用和禁用滚动效果很好。

    #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

有解决这个问题的办法吗?如果有人不明白我的解释请检查 my demo project
任何帮助或建议将不胜感激

最佳答案

问题是在 iOS 8 中,更改 scrollEnabled 时 contentSize 没有正确调整。对 enableScrollButtonPressed 方法稍作调整即可成功解决该问题。

-(IBAction)enableScrollButtonPressed:(id)sender
{
self.myTextView.scrollEnabled = YES;
self.myTextView.contentSize = [self.myTextView sizeThatFits:self.myTextView.frame.size];
}

关于ios - UITextView scrollEnabled = YES 在 iOS8 中设置 scrollEnabled = NO 后不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37152494/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com