-1

I need to perform button action at the end of UIlabel. But its not link to web page. I need to navigate to a new ViewController.

ex: "industry's standard dummy text ever since the 1500s, when an unknown printer took … READ MORE."

here READ MORE is button. When user hit that word I need to move the user to a new UIViewController. is this possible? or is there any other way to solve this?

Sarath
  • 343
  • 3
  • 12
  • Related: https://stackoverflow.com/questions/42240683/how-do-i-detect-and-make-clickable-links-in-a-uilabel-not-using-uitextview – Sweeper Feb 08 '19 at 14:24
  • You can use textView+NSMutableAttributedString for creating link, no need use UIButton and UILabel. – guru Feb 08 '19 at 14:25
  • 1
    everything is possible. – holex Feb 08 '19 at 14:33
  • @Sweeper please read the question again I'm not asking about clickable link. I'm asking about moving to new viewController by clicking last two Words. – Sarath Feb 08 '19 at 14:33
  • But the last two words must be a link for them to be clickable, right? The linked question seem to also show how you can detect the click. – Sweeper Feb 08 '19 at 14:35

1 Answers1

0

You are thinking webpage way. You should start thinking more in iOS way.

Is it possible YES! You could get the click location inside the UILabel and know if it was on the last 2 words. Pls don't do it.

Or textView+NSMutableAttributedString. Both is too much overhead for a simple feature.

Approach one: end the UILabel with "..." and if you click anywhere in the label, it's goes to the full text view controller (or get bigger and show the entire text)

Approach two: If using a table, you can add a disclosure arrow image to the cell. If click the cell, then go to full view. The user will understand.

Approach three: Add a button at the end of your UILabel with the "read more"

alegelos
  • 2,308
  • 17
  • 26