1

I have an NSAttributedString below:

NSMutableAttributedString *myString = [[NSMutableAttributedString alloc] initWithString:@"This is my attributed text. Click on here to go to a new controller."];

I want to make the word here be an event passing to a new UIViewController. So I want the work "here" to be tapped and passed to a new view.

How do I add a UIButton in there or a tap gesture to it? (Side note, the string can change and the "here" won't always be in the same place).

cdub
  • 24,555
  • 57
  • 174
  • 303
  • Check this: http://stackoverflow.com/questions/19332283/detecting-taps-on-attributed-text-in-a-uitextview-on-ios-7 – Mrunal Dec 14 '14 at 08:46
  • True but mine is in a UILabel too. – cdub Dec 14 '14 at 08:53
  • 1
    You can used that UITextView which looks like label. – Mrunal Dec 14 '14 at 08:56
  • or put UIButton on that specific position and make transition... – Fahim Parkar Dec 14 '14 at 08:59
  • How do you put a UIButton on that specific position? You mean like an overlay or is there a way to add it in as an attribute somehow? – cdub Dec 14 '14 at 09:02
  • Possible duplicate of [Add a regular action to an NSAttributedString?](http://stackoverflow.com/questions/27908596/add-a-regular-action-to-an-nsattributedstring) – MrTJ Mar 17 '17 at 13:59

0 Answers0