Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8569449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:20:13+00:00 2026-06-11T18:20:13+00:00

It seems that a common way to make a text behave like a link

  • 0

It seems that a common way to make a text behave like a link on iOS is to make it a UIButton, but I noticed the UIButton’s addTarget or gestureRecognizer’s addTarget both don’t have an argument that can be passed to the method when the button is pressed?

The situation is, from a server, we may get back a list of words, such as “pineapple”, “apple”, “orange”, and the numbers can vary. These words are displayed on screen, and pressing the word will invoke a ViewController to replace the main view controller.

It seems that one way is to use UIButton’s tag, so when we set up the button, we give it a tag of 0, and in another array of the current view or view controller, make element 0 point to an NSString object, containing the word “pineapple”. And so in the handler, the tag can be obtained, and it can be used to retrieve the string. But is this the only way, because it seems not very structural. Is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:20:15+00:00Added an answer on June 11, 2026 at 6:20 pm

    My knee-jerk answer was to simply suggest that you subclass the UIButton. Whenever you want to add a property to an existing class, “subclass” is the first answer that comes to mind. But when I tried subclassing the UIButton, it did not work well. Searching for for “UIButton subclass” I discover that this is a well known issue with several recommended solutions:

    • Subclass UIButton to add a property
    • objective C: Buttons created from subclass of UIButton class not working
    • create uibutton subclass

    I’ve tried both creating a category with associative references as well as the simplistic approach of just subclassing a UIView instead, and make the desired button a subview of that. Both approaches work fine. But the intuitively attractive option of just subclassing UIButton does not work well.

    But while the various work-arounds for adding properties to UIButton objects work, they seem sufficiently unintuitive that, I’d be inclined to go back to something simple, such as using the tag numbers in an array or dictionary, rather than pursuing these cumbersome button subclassing techniques.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a Rails app, and it seems that common practice is to
It seems that the following is a common method given in many tutorials on
Seems that This will be an easy question for you but this problem is
Ok, so this seems like a common need. A little googling finds a lot
So I have, what would seem like a common question that I can't seem
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch
It seems that we can show layers and even use a different zPosition for
It seems that runClasses() doesn't terminate the code being tested even after the test
It seems that JavaScript's Date() function can only return local date and time. Is
It seems that often I find that my code when moving either from one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.