我禁用了编辑,但是如何禁用弹出的选择界面?我不希望用户能够突出显示文本或复制文本等。
保持垂直滚动非常重要。
答案 0 :(得分:2)
textView.userInteractionEnabled = NO;
好的,如果你需要保留滚动,那么创建一个scrollView,将其设置为插座并在其上添加textview。
然后在viewWillAppear中设置textview的高度:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.descriptionTextView.text = @""; // set some text to determine the total height
self.descriptionTextView.frame = CGRectMake(self.descriptionTextView.frame.origin.x,
self.descriptionTextView.frame.origin.y,
self.descriptionTextView.frame.size.width,
self.descriptionTextView.contentSize.height);
self.descriptionTextView.userInteractionEnabled = NO;
//next set new content size for scroll view
self.descriptionScrollView.contentSize = CGSizeMake(self.descriptionScrollView.frame.size.width,
self.descriptionTextView.frame.origin.y + self.descriptionTextView.frame.size.height);
}
答案 1 :(得分:0)
快捷键4 , Xcode 10
确保将委托设置为YourViewController
yourTextView.delegate = yourViewControllerInstance
然后,这将禁用突出显示,启用点击链接并允许滚动
extension YourViewController: UITextViewDelegate {
func textViewDidChangeSelection(_ textView: UITextView) {
view.endEditing(true)
}
}