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

  • Home
  • SEARCH
  • 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 8600965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:44:09+00:00 2026-06-12T01:44:09+00:00

I have button in my view with a setAction to a local function. in

  • 0

I have button in my view with a setAction to a local function.
in GameOptions.m i have the next function:

- (void) changeSettings (UIBarButtonItem *) sender  {

// do something 
}

and a button that start it in GameOptions.m :

[btn1 addTarget:self action:@selector(changeSettings:) forControlEvents:UIControlEventTouchUpInside];

now i moved it from his view to a navigation controller as an rightBrButtonItem.
the myVC is an instance of small UIViewController with all the navigationBar settings,and each time i using pop ,push to it .

   UIBarButtonItem *buttonNav1 = [[UIBarButtonItem alloc] initWithCustomView:settingsView];
        [myVC.navigationItem setRightBarButtonItem:buttonNav1];

the problem is that this button is not in his GameOptions class and i want it to start the same function with implementation in GameOptions.m.

I would like to do the next thing :

buttonNav1 setAction:changeSettings;

but its impossible, the changeSetting is not recognized…

Tried : buttonNav1.action = self. but i’m not getting this function, only functions without parameters.
How can i call to chnageSettings from that button in navigationBar

  • 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-12T01:44:11+00:00Added an answer on June 12, 2026 at 1:44 am

    All you need to do is inform your UIBarButtonItem of the existence of the GameOptions object.
    That’s what you were doing using self in :

    [btn1 addTarget:self action:@selector(changeSettings:) forControlEvents:UIControlEventTouchUpInside];

    Just after instanciating your UIBarButtonItem *buttonNav1, you can send it the message addTarget:action:forControlEvents: or, if you want to use setAction, don’t forget to also use setTarget.

    So now, your question is: what is the most elegant/efficient way to pass the GameOptions object’s pointer to the UIBarButtonItem 😉

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

Sidebar

Related Questions

I have a an object view with data and a button on that view.
I have a button in a view which refuses to work. I've got in
I have a button created in my view. In the ViewModel, I wish to
We have place a button on a view. When we press it, nothing happens.
I have a view with which I have a button calling the following method.
I am new to iphone development. I have created a button in the view.
i have view controller which contains a button which show the image library ,if
I have a view containing a button. And i want to perform an action
I have a view with a button at the bottom of the portrait screen,
I have a view with a button and three UITextFields. The view's background is

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.