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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:29:48+00:00 2026-06-17T08:29:48+00:00

when clicking the button action down below, I get an exception: -[UIRoundedRectButton selectedSegmentIndex]: unrecognized

  • 0

when clicking the button action down below, I get an exception:

-[UIRoundedRectButton selectedSegmentIndex]: unrecognized selector sent to instance 0x8178b90 ;
‘

(it is also initialized as – (IBAction)genderBtn:(id)sender; in the header file).

I do not know if I should somehow initialize this into another method or not or initialized globally. Any method ideas would be much appreciated.

- (IBAction)submitButton:(id)sender {

  double BAC=0;

  //  NSString *weight=weightTextField.text;

  //Other variables etc.

UISegmentedControl *gender = (UISegmentedControl *)sender;


   UIButton *gender = (UIButton *)sender;


if (gender.selected == 0 ) {



} else if (gender.selected = 1){



}


UIAlertView *alertMessage = [[UIAlertView alloc] initWithTitle:@"Your Results:"
                                          message:[NSString stringWithFormat:@" Your Percentage is: "]
                                         delegate:self
                                cancelButtonTitle:@"OK"
                                otherButtonTitles:nil];

[alertMessage show];
}
  • 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-17T08:29:49+00:00Added an answer on June 17, 2026 at 8:29 am

    The error is saying that although you think the sender value is a UISegmentedControl, it isn’t. It’s a UIRoundedRectButton. The result is that you end up sending a message to which only a UISegmentedControl implements to the UIRoundedRectButton, thus it does not recognize the selector. Make sure this action is connected to the right type of button.


    EDIT: Alright. I looked at your code from before. I thought the problem was that you used a normal UIButton instead of a UISegmentedControl, but the problem seems to really be that you shouldn’t be using the sender argument at all.

    I take it that you have one UISegmentedControl for the user to select something, and one UIButton for them to tap when they’re done with their selection. The problem was that you were asking the sender argument (which was the submit button) what the selection state of the UISegmentedControl was. You need to store the UISegmentedControl in a property and use that in your submit method to get the selectedSegmentIndex.

    - (IBAction)submitButton:(id)sender {
    
        double BAC=0;
    
        //NSString *weight=weightTextField.text;
    
        //Other variables etc.
    
        UISegmentedControl *gender = self.segmentedControl;
    
    
        if (gender.selectedSegmentIndex == 0 ) {
            //something
        } else if (gender.selectedSegmentIndex == 1){
            //something
        }
    
        UIAlertView *alertMessage = [[UIAlertView alloc] initWithTitle:@"Your Results:"
                                              message:[NSString stringWithFormat:@" Your Percentage is: "]
                                             delegate:self
                                    cancelButtonTitle:@"OK"
                                    otherButtonTitles:nil];
    
        [alertMessage show];
    }
    

    The submit button calls this when it is pressed and gets the selected index from the segmented control which you store in a property.

    @property (weak, nonatomic) IBOutlet UISegmentedControl* segmentedControl; //goes in @interface
    
    @synthesize segmentedControl = _segmentedControl; //goes in @implementation
    

    Hook this IBOutlet to your segmented control and use that.

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

Sidebar

Related Questions

Is it possible to disable standard action being performed while clicking radio button? (without
Javascript run at page opening or later by user action like clicking a button
I use watir for testing in RadRails IDE.After clicking button Delete appears window Message
On clicking a button, I want the selected rows to be inverted (non-selected rows
Iam in parent view while clicking the button in the parent view I want
I have an updatepanel which after clicking one button is submitting the page. The
I need to call a function by clicking a button. The button is on
I want to send my Application to background simply clicking on Button inside my
I m trying to refresh the screen on clicking a button so i want
I am working on a dynamic search view wherein clicking a button should add

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.