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 4024434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:43:16+00:00 2026-05-20T10:43:16+00:00

in my app i call a UIView and that UIView is like a settings

  • 0

in my app i call a UIView and that UIView is like a settings screen in my app and i have buttons in the UIView and my question is how do i add actions to the buttons iv added to the UIViews subview? thanks,

  • 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-05-20T10:43:17+00:00Added an answer on May 20, 2026 at 10:43 am

    Assuming you’re writing code in a view controller for your settings UIView, the UIView is properly bound to the view property of your controller, and you have referenced one of the buttons with a variable button, here is what you would write:

    - (void)viewDidLoad {
        [super viewDidLoad];
        [button addTarget:self
                   action:@selector(buttonPressed)
         forControlEvents:UIControlEventTouchUpInside];
    }
    
    - (void)buttonPressed
    {
        // do things here in response to the button being pressed
    }
    

    Another way to write that method is passing in a pointer to the button which was actually pressed, like so:

    - (void)viewDidLoad {
        [super viewDidLoad];
        [button addTarget:self
                   action:@selector(buttonPressed:) // note the extra colon here
         forControlEvents:UIControlEventTouchUpInside];
    }
    
    - (void)buttonPressed:(id)sender
    {
        UIButton *buttonWhichWasPressed = (UIButton *)sender;
        // now you can do things like hide the button, change its text, etc.
    }
    

    Rather than calling addTarget:action:forControlEvents:, though, in Interface Builder (you should be doing this) after defining the buttonPressed or buttonPressed: method above, in the .xib file with the button go to the second tab in the Inspector after clicking on the Button (it should say Button Connections), and click-drag the Touch Up Inside event to File’s Owner, and select “buttonPressed” from the list.

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

Sidebar

Related Questions

I'm like working on an app that will call home when I press down
I have an app that uses OpenGL-ES and an EAGLContext within a UIView -
I have an iPad app that has draggable UIViews contained in a larger parent
This is probably a simple question... I have a UIView with a button that
In my app I have a custom UIView subclass (let's call it MyView) which
I have an iPad app using Storyboards. I have a UIView that I have
I'm trying to debug an android app that call native code to do some
Is there an API that my Google App Engine app can call when signed
My app makes a call to an API that returns a dictionary. I want
In my app I want to call to selected number. For this I have

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.