iOS TTTAttributedLabel委托didSelectLinkWithURL未被调用

Jua*_*anD 12 label delegates hyperlink ios

我在项目中设置TTTAttributedLabel时遇到问题.

我在头文件中设置了协议委托

@interface TwitterFeedControlleriPad : UIViewController <TTTAttributedLabelDelegate, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateWaterfallLayout>
Run Code Online (Sandbox Code Playgroud)

我已经将ViewController设置为它(不是nil,我已经检查过了).

cell.tweetLabel.delegate = self;
Run Code Online (Sandbox Code Playgroud)

它显示标签中的所有链接,但是当我点击它们时它不会调用该功能.

- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url
Run Code Online (Sandbox Code Playgroud)

我之前已经成功使用它,它的代码完全相同!这让我疯狂!

Joe*_*ran 46

我知道这不是你的情况,但这适用于所有遇到同样问题并且偶然发现这个问题的人.

我有一个UITapGestureRecognizer与之相同的观点TTTAttributedLabel.由于第一个,没有调用' touchEnded'的功能TTTAttributedLabel,它负责处理点击链接.

我通过添加以下行来解决问题: tapGestureRecognizer.cancelsTouchesInView = NO;


Jua*_*anD 5

解决了!问题是 CollectionViewCell 中的“启用用户交互”复选框......它被禁用了!我花了4个小时才弄明白!!还是很感谢你!