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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:07:08+00:00 2026-06-13T22:07:08+00:00

Does anybody know how to check what segmented Control has triggered the event? I

  • 0

Does anybody know how to check what segmented Control has triggered the event? I am creating two cells which contain segmented Controls. In the method segmentedControlIndexChanged I want to know which segmented Control has triggered the event. I used tag, but it isn’t working. I am new with this. I would appreciate your help.

The Code for the cells, which contain segmented Controls:

 cellParinti = [[Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
cellParinti.textLabel.text = @"Parinti";
cellParinti.label.text = dog?dog.parinti:@"";
cellParinti.segmentedControl.selectedSegmentIndex = [dog.parinti isEqualToString:@"da"] ? 0 : 1;
cellParinti.segmentedControl.tag = 1;
[cellParinti.segmentedControl addTarget:self action:@selector(segmentedControlIndexChanged:) forControlEvents:UIControlEventValueChanged];
[cellParinti addSubview:cellParinti.textLabel];
[cellParinti addSubview:cellParinti.label];
[cellParinti addSubview:cellParinti.segmentedControl];


cellPedigree = [[Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
cellPedigree.textLabel.text = @"Pedigree";
cellPedigree.label.text = dog?dog.pedigree:@"";
cellParinti.segmentedControl.tag = 2;
cellPedigree.segmentedControl.selectedSegmentIndex = [dog.pedigree isEqualToString:@"da"] ? 0 : 1;
[cellPedigree.segmentedControl addTarget:self action:@selector(segmentedControlIndexChanged:) forControlEvents:UIControlEventValueChanged];

[cellPedigree addSubview:cellPedigree.textLabel];
[cellPedigree addSubview:cellPedigree.label];
[cellPedigree addSubview:cellPedigree.segmentedControl];

The code for the method, which has been triggered:

-(void) segmentedControlIndexChanged:(id)sender{
NSIndexPath *indexPath;

UISegmentedControl * sg1 = (UISegmentedControl *)sender;

// reload data based on the new index
if (sg1.tag == 1){
cellParinti.label.text = sg1.selectedSegmentIndex == 0 ? @"da" : @"nu";
dog.parinti = sg1.selectedSegmentIndex == 0 ? @"da" : @"nu";
}
else {
    cellPedigree.label.text = sg1.selectedSegmentIndex == 0 ? @"da" : @"nu";
    dog.pedigree = sg1.selectedSegmentIndex == 0 ? @"da" : @"nu";
}

}

  • 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-13T22:07:09+00:00Added an answer on June 13, 2026 at 10:07 pm

    You have

    cellParinti.segmentedControl.tag = 2;
    

    I think this should be

    cellPedigree.segmentedControl.tag = 2;
    

    It is a typo in your code, which is preventing you from getting the correct tag.

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

Sidebar

Related Questions

Does anybody know of a good algorithm to mutually exclusively check two properties using
Does anybody know how to check for a valid IMEI? I have found a
Does anybody know, how to check if broadcast is online or offline in Icecast2
Does anybody know how to check the permissions on the local system account on
Hee Does anybody know how to check in-application if a mail account is setup
Does anybody know how I can programmatically check (using C#) whether my program will
Does anybody know of a way I can check what permissions the Local System
Does anybody know if it is possible to check what page a user is
Does anybody know of a way to have my application constantly check firstly if
Does anybody know how can I check the retain count of an object while

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.