I disabled user interaction for a textview from the interface, and I want to enable it when double tapping on the textview, I tried this by using UITapGestureRecognizer but it seems to not be working when user interaction is disabled ?!
Any help ?
I disabled user interaction for a textview from the interface, and I want to enable it when double tapping on the textview, I tried this by using UITapGestureRecognizer but it seems to not be working when user interaction is disabled ?!
Any help ?
如果您禁用它们,您的文本视图将不会识别任何用户交互,甚至手势。您可以在 textview 上放置一个标签作为叠加层,并在其中添加手势识别器。
当您想禁用 textview 上的用户交互时,应添加此叠加层
UILabel *overlay = [[UILabel alloc] initWithFrame:textview.frame];
overlay.backgroundColor = [UIColor clearColor];
如果您添加覆盖,您甚至不需要禁用文本视图上的用户交互,因为覆盖不会将任何用户交互传递给文本视图。再次与 textview 交互只需删除覆盖。(最好的方法是让它成为一个属性并做类似的事情[self.overlay removeFromSuperView]
)。