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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:05:02+00:00 2026-05-13T15:05:02+00:00

I am working on a core data using app and one of the views

  • 0

I am working on a core data using app and one of the views is EditingViewController, which acts as the controller for a number of ui elements which describe the attributes of objects. Inside the EditingViewController, all of my ui elements are being called and hidden with the .hidden = YES/NO; operation. One of my ui elements is a uipickerview. Currently, there is one array for each of two different views. Meaning that if they clicked on the first name field, array1 would load in picker1, and they would pick from it, and then if they clicked on last name, array2 would load in picker2, and life is good. Here is my code I am using to make this work up until now:

- (NSString *)pickerView:(UIPickerView *)picker titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
if (picker1 == self.picker) {
    return [array1 objectAtIndex:row];
} else {
    return [array2 objectAtIndex:row];
}
}

But! array1 is so big that I would like to add a UISegmentedControl to picker1 so that it can sort array1’s info a little better. I know that UISegmentedControl is just a pretty set of buttons, requiring IBActions to be linked and stuff, but how could I implement it so that in one of my views, the first one, just picker1 and array1 are managed by the UISegmentedControl? Is it possible to make it so that it is just a smooth sorting process? I figure I will break down array1 into other arrays based on the conditions I set in my UISegmentedControl, how do I link those so they look and work good? Any help on this topic as always is greatly appreciated! 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-13T15:05:03+00:00Added an answer on May 13, 2026 at 3:05 pm

    Use the selectedSegmentIndex property.

    For example:

    enum {
        SEGMENT1,
        SEGMENT2,
        SEGMENT3
    };
    
    - (NSString *)pickerView:(UIPickerView *)picker titleForRow:(NSInteger)row forComponent:(NSInteger)component;
    {
        if (picker1 == self.picker) {
            if (segmentedControl.selectedSegmentIndex == SEGMENT1) {
                return [array1sub1 objectAtIndex:row];
            } else if (segmentedControl.selectedSegmentIndex == SEGMENT2) {
                return [array1sub2 objectAtIndex:row];
            } else if (segmentedControl.selectedSegmentIndex == SEGMENT3) {
                return [array1sub3 objectAtIndex:row];
            }
        } else {
            return [array2 objectAtIndex:row];
        }
    }
    
    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
        if (picker1 == self.picker) {
            if (segmentedControl.selectedSegmentIndex == SEGMENT1) {
                return [array1sub1 count];
            } else if (segmentedControl.selectedSegmentIndex == SEGMENT2) {
                return [array1sub2 count];
            } else if (segmentedControl.selectedSegmentIndex == SEGMENT3) {
                return [array1sub3 count];
            }
        } else {
            return [array2 count];
        }
    }
    

    Also, you will want to reload the picker when the segmented control changes, so you should link the segmented control’s value-changed event with a method like this:

    - (IBAction)handleValueChanged
    {
        [self.picker reloadAllComponents];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a site which is at the core/ master of a number
I'm working on designing the kernel (which I'm going to actually call the core
I'm working with a CMS, Joomla, and there's a core class which renders a
I'm working on a source-code visualization project that uses the Processing core library. The
I'm working with CoreData in Cocoa (not document-based). My problem is, that I want
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project at the moment and we have to implement soft deletion
Working on a somewhat complex page for configuring customers at work. The setup is
Working on a project that parses a log of events, and then updates a

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.