How to customize UILabel clickable

后端 未结 8 2057
余生分开走
余生分开走 2020-11-30 02:28

What I want:

In an iPhone app, I\'d like to show information in a tableView. In each cell, the text is like: John recently listen to music abcdefg.mp3. and if neede

相关标签:
8条回答
  • 2020-11-30 03:13

    By adding UITapGestureRecognizer to the label, to make UIlabel clickable.

    Before adding the label to tapgesture, don't forgot to enable userinteraction for UIlabel

    Here is the sample code:

    //Tap Gesture
    UITapGestureRecognizer* gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(userTapped:)];
    //Adding userinteraction for label
    [labelName setUserInteractionEnabled:YES];
    //Adding label to tap gesture
    [labelName addGestureRecognizer:gesture];
    
    0 讨论(0)
  • 2020-11-30 03:16

    Sounds similar to what they accomplished in Twitteriffic with Fancy UILabels. Basically, Craig Hockenberry made his own custom "data detector", so that he could insert links within labels and multi-line text. See this question: Is there a way to create custom UIDataDetectorTypes?

    0 讨论(0)
提交回复
热议问题