gpt4 book ai didi

ios - 无法在 UIScrollView 中选择/编辑 UITextView 中的文本

转载 作者:行者123 更新时间:2023-11-29 01:43:21 25 4
gpt4 key购买 nike

我已经使用 Masonry 设置了带有 subview 的 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 交互。这里的什么元素阻止了用户交互? Screenshot

最佳答案

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

make.edges.equalTo(self.scrollView);

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

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

关于ios - 无法在 UIScrollView 中选择/编辑 UITextView 中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32179504/

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