gpt4 book ai didi

ios - 如何单击UITextView中的链接并同时获取“点击”位置

转载 作者:行者123 更新时间:2023-12-01 19:01:31 29 4
gpt4 key购买 nike

我使用NSAttributedString在UITextView中添加了一些链接,当用户单击链接时,我想向用户显示一个“注释”。问题是我不知道如何获得用户点击以打开链接的点击位置。

最佳答案

覆盖hitTest:withEvent方法

签名

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

上面的方法是CGPoint提供的,它是touch的位置。创建CGPoint类属性并将touch-location存储在其中。
@property (nonatomic,assign) CGPoint previousTouch;

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
self.previousTouch = point;
return [super hitTest:point withEvent:event];
}

关于ios - 如何单击UITextView中的链接并同时获取“点击”位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22533825/

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