我在scrollview中创建了textview和imageview并标记,我添加textView.isScrollEnabled = false
来滚动它们。
我的问题是,当我在最后一行的文本视图中单击输入时,我的textview变大但不滚动到底部!光标切断了!
但我想要这个...
与此GIF类似。
我的代码
noteTextView.isScrollEnabled = false
photoImageView.translatesAutoresizingMaskIntoConstraints = false
noteTextView.translatesAutoresizingMaskIntoConstraints = false
bScrollView.translatesAutoresizingMaskIntoConstraints = false
dateLabel.translatesAutoresizingMaskIntoConstraints = false
nView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(bScrollView)
view.sendSubview(toBack: bScrollView)
bScrollView.addSubview(nView)
nView.addSubview(photoImageView)
nView.addSubview(dateLabel)
nView.addSubview(noteTextView)
bScrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
bScrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
bScrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
bScrollView.topAnchor.constraint(equalTo: topView.bottomAnchor).isActive = true
nView.leadingAnchor.constraint(equalTo: bScrollView.leadingAnchor).isActive = true
nView.trailingAnchor.constraint(equalTo: bScrollView.trailingAnchor).isActive = true
nView.bottomAnchor.constraint(equalTo: bScrollView.bottomAnchor).isActive = true
nView.topAnchor.constraint(equalTo: bScrollView.topAnchor).isActive = true
nView.widthAnchor.constraint(equalTo: bScrollView.widthAnchor).isActive = true
noteTextView.leadingAnchor.constraint(equalTo: nView.leadingAnchor, constant: 18).isActive = true
noteTextView.trailingAnchor.constraint(equalTo: nView.trailingAnchor, constant: -18).isActive = true
noteTextView.bottomAnchor.constraint(equalTo: nView.bottomAnchor).isActive = true
noteTextView.topAnchor.constraint(equalTo: dateLabel.bottomAnchor).isActive = true
noteTextView.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true
photoImageView.leadingAnchor.constraint(equalTo: nView.leadingAnchor).isActive = true
photoImageView.trailingAnchor.constraint(equalTo: nView.trailingAnchor).isActive = true
photoImageView.topAnchor.constraint(equalTo: nView.topAnchor).isActive = true
photoImageView.heightAnchor.constraint(equalToConstant: 300).isActive = true
dateLabel.leadingAnchor.constraint(equalTo: nView.leadingAnchor, constant: 12).isActive = true
dateLabel.trailingAnchor.constraint(equalTo: nView.trailingAnchor, constant: -12).isActive = true
dateLabel.topAnchor.constraint(equalTo: photoImageView.bottomAnchor).isActive = true
dateLabel.heightAnchor.constraint(equalToConstant: 30).isActive = true