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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:02:36+00:00 2026-06-01T03:02:36+00:00

I am trying to create a two component UIPickerView, the left side of which

  • 0

I am trying to create a two component UIPickerView, the left side of which holds the values of playing cards (two, three, Jack, etc.) and the right side of which holds images of the four suits. Here is the relevant code:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
      return 2;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component {
      if (component == 0)
            return [self.values count];
      return [self.column1 count];
}


- (NSString *)pickerView:(UIPickerView *)pickerView
         titleForRow:(NSInteger)row
        forComponent:(NSInteger)component {
      if (component == 0)
            return [self.values objectAtIndex:row];
      else 
            return nil;
}

- (UIView *)pickerView:(UIPickerView *)pickerView
        viewForRow:(NSInteger)row
      forComponent:(NSInteger)component reusingView:(UIView *)view {
      if(component == 1){
          NSString *arrayName = [[NSString alloc] initWithFormat:@"column1"];
          NSArray *array = [self valueForKey:arrayName];
          return [array objectAtIndex:row];
      }
      else
           return nil;
}

As you can probably see, I have attempted to create a separate picker delegate method for the left component and the right component. However, this is not giving me the intended results. The code seems to only run the viewForRow method, ignoring the other. Thus, I end up with the right component filled with images and the left component empty. Does anybody know of a different way to populate both components?

  • 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-01T03:02:38+00:00Added an answer on June 1, 2026 at 3:02 am

    Probably as soon, as you implement viewForRow:, it wins over titleForRow:.

    Just return an UILabel with the needed text. After all titleForRow: doesn’t do anything else. It’s just a more convinient way, if you ONLY need labels.

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

Sidebar

Related Questions

I'm trying to create two a regex to add quotes to some values in
I'm playing around with MVC3, trying to create small test projects which simulate problems
I'm trying to create two ASP.NET Membership login pages for an ASP.NET website I'm
I am trying to create two different sets of settings for datepicker( http://keith-wood.name/datepick.html )
I am trying to create two select lists both filled with the same times.
I'm trying to create two functions: get & set, that both accept an arbitrary
I am trying to create two thumbnails of an image uploaded by user. I
I'm trying to create a two-level horizontal navigation menu (or menubar) that displays the
I'm trying to create a two dimensional array like this... @transactions = {} @expenses.each
I'm trying to create a standard two-column form, where the first column is 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.