我在我的项目中设置 TTTAttributedLabel 时遇到问题。
我已经在我的头文件中设置了协议(protocol)委托(delegate)
@interface TwitterFeedControlleriPad : UIViewController <TTTAttributedLabelDelegate, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateWaterfallLayout>
我已经将 ViewController 设置为它(不是零,我已经检查过了)。
cell.tweetLabel.delegate = self;
它在标签中显示了所有链接,但是当我点击它们时它没有调用该函数。
- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url
我之前已经成功地使用过它,它是完全相同的代码!!这让我发疯!
最佳答案
我知道这不是你的情况,但这适用于遇到与我相同的问题并偶然发现此线程的每个人。
我在与 TTTAtributedLabel
相同的 View 上有一个 UITapGestureRecognizer
。由于第一个,TTTAtributedLabel
的“touchEnded
”函数没有被调用,它负责处理点击的链接。
我通过添加以下行解决了这个问题:tapGestureRecognizer.cancelsTouchesInView = NO;
关于iOS TTTAttributedLabel 委托(delegate) didSelectLinkWithURL 没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17796512/