Ho il seguente codice e voglio rendere le parti del mio testo selezionabili e chiamare un altro UIViewController (non un sito Web).Aggiungere un evento click a un testo in ios NSString
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"testing it out @clickhere"];
NSInteger length = str.length;
[str addAttribute:NSForegroundColorAttributeName value:[UIColor bestTextColor] range:NSMakeRange(0,length)];
Il NSMutableAttributedString viene impostato su un UILabel in questo modo:
label.attributedText = str;
cosa è il modo migliore per fare questo? Non riesco a trovare una grande risposta.
Un esempio di quello che voglio è supponiamo Ho un UILabel in questo modo con il seguente testo:
This is my label. Click here to go to UIViewController1 and then go to UIViewController1 by this #tag.
voglio il testo "qui" per essere passato per il primo evento click e la parola "# tag "da passare allo stesso evento click.
Vedere se questo lui lps: http://stackoverflow.com/questions/8811909/getting-the-word-touched-in-a-abelabel-uitextview/21577829#21577829 Prova anche questo: http://stackoverflow.com/questions/15293426/how -di-creare-uilabel-con-cliccabile-prima parola – iOSAaronDavid
Perché duplicare: http://stackoverflow.com/questions/28018707/add-a-pag-gesture-to-a-part-of-a-uilabel? – Larme