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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:52:51+00:00 2026-06-03T05:52:51+00:00

Good day. I try to add event to segment control, but it always take

  • 0

Good day. I try to add event to segment control, but it always take me an exeption. I create a property in class

#import <UIKit/UIKit.h>

@interface Events : UINavigationController{
    UISegmentedControl *segmentedControl;
}
@property (nonatomic, retain) UISegmentedControl *segmentedControl;
-(void)changeSegment:(id)sender;
@end

And in .m file I add a subview

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
         self.segmentedControl = [[UISegmentedControl alloc] initWithItems:
                                                [NSArray arrayWithObjects:
                                                 [NSString stringWithString:NSLocalizedString(@"Трансляции", @"")],
                                                 [NSString stringWithString:NSLocalizedString(@"Мафия", @"")],

                                                 nil]];
        segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleWidth;
        segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
        [segmentedControl setSelectedSegmentIndex:0];



        //[segmentedControl setFrame:[self.navigationBar bounds]];
        CGRect rect = [self.navigationBar bounds];
        rect.size.width = rect.size.width - 40;
        rect.size.height = rect.size.height - 15;
        rect.origin.y =  rect.origin.y + 7;
        rect.origin.x =  rect.origin.x + 17;
        [segmentedControl setFrame:rect];

        [self.navigationBar addSubview:segmentedControl];

    }
    return self;
}

Then In ViewDidLoad I try to add event

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.segmentedControl addTarget:self action:@selector(changeSegment:) 
               forControlEvents:UIControlEventValueChanged];

}

And the description of events

-(void)changeSegment{
    if(segmentedControl.selectedSegmentIndex == 0){

    }
    if(segmentedControl.selectedSegmentIndex == 1){

    }
}

But it never enter to this function. And give me error [Events changeSegment:]: unrecognized selector sent to instance 0x6833bf0

  • 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-03T05:52:52+00:00Added an answer on June 3, 2026 at 5:52 am

    You declared -(void)changeSegment:(id)sender and added the selector @selector(changeSegment:) to your segment control, however, you implemented -(void)changeSegment or @selector(changeSegment), notice the missing :.

    Just change this:

    -(void)changeSegment{
        if(segmentedControl.selectedSegmentIndex == 0){
    
        }
        if(segmentedControl.selectedSegmentIndex == 1){
    
        }
    }
    

    To this:

    -(void)changeSegment:(id)sender{
        if(segmentedControl.selectedSegmentIndex == 0){
    
        }
        if(segmentedControl.selectedSegmentIndex == 1){
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day everyone. I have an audio class, that plays a .wav file. But
Good day. When i try to run the example from MSDN. But it failed
Good day, i will try and explain myself here. i am trying to create
Good day. I try to add new tab with navigation controller to my app.
Good day. I try to create web service server with yii and client for
Good day, I have the following problem: class B extends class A and methods
Good day, i will try to explain my problem as best as i can.
Good day. I try to use jqGrid in my web project. everything is good
Good time of day! I successfully used apache + php on windows 7, but
I have been looking for a good solution all day, but Google evolves so

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.