无法在 UIScrollView 的 UITextView 中 select/edit 文本

Cannot select/edit text in UITextView within UIScrollView

我已经使用 Masonry 设置了带有子视图的 UIScrollView:

- (void)setupViews {
    self.view.backgroundColor = [UIColor Background];
    self.scrollView = [UIScrollView new];
    self.scrollView.alwaysBounceVertical = YES;
    [self.view addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    self.contentView = [UIView new];
    [self.scrollView addSubview:self.contentView];
    self.scrollView.backgroundColor = [UIColor clearColor];
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.scrollView);
        make.left.and.right.equalTo(self.view);
    }];
    self.imageButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.imageButton sd_setImageWithURL:[NSURL URLWithString:self.card.cardImageURL] forState:UIControlStateNormal];
    [self.imageButton.imageView setContentMode:UIViewContentModeScaleAspectFill];
    [self.contentView addSubview:self.imageButton];
    [self.imageButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.and.right.equalTo(self.contentView);
        make.height.equalTo(self.imageButton.mas_width).multipliedBy(3/4.0);
    }];
    self.textField = [UITextField new];
    self.textField.backgroundColor = [UIColor whiteColor];
    self.textField.font = kFontRegular(14);
    self.textField.text = self.card.cardTitle;
    [self.contentView addSubview:self.textField];
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(8);
        make.top.equalTo(self.imageButton.mas_bottom).with.offset(8);
        make.right.equalTo(self.contentView).with.offset(-8);
        make.height.equalTo(@(45));
    }];
}

但它不允许我与 UITextField 交互。这里的什么元素阻止了用户交互?

您的 contentView 的高度将为零。所以它永远不会得到一些触摸事件。你不应该使用这个约束:

make.edges.equalTo(self.scrollView);

它不会得到正确的值。尝试为您的 contentView 设置顶部和高度限制。

make.top.equalTo(@0);
make.height.equalTo(@700);