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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:51:48+00:00 2026-05-28T20:51:48+00:00

I am writing code to programmatically create a view. In this view I am

  • 0

I am writing code to programmatically create a view. In this view I am creating two UIPickerViews, however, as the title explains, when I go to populate the lists with data, all of the data goes into the second table, and none in the first. I can see where exactly the problem is, but don’t know how to fix it. Here is the code with editing around non-related parts.

in the below section is where i create the pickerview. Essentially I have a large list of data. If i see any occurance of “RadioButton” I create a PickerView. RadioButton can appear more than once and is where my issue lies.

 for(int i = 0; i < [list count]; i++){  
 ...

 else if([input.controlTypeName compare:@"RadioButton"] == NSOrderedSame){
        [radioList addObject:input.sourceText]; 
        radioPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(50, y, 220, 200)];
        radioPicker.delegate = self;
        radioPicker.showsSelectionIndicator = YES;
        [inputsView addSubview:radioPicker];
        y = y+220;

    }

the delegate methods are as follows..

       - (void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component {
// Handle the selection
}

// tell the picker how many rows are available for a given component
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {

if([pickerView isEqual: radioPicker]){
    return [radioList count];
}




 // tell the picker how many components it will have
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
   return 1;
}

 // tell the picker the title for a given component
 - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {

  if([pickerView isEqual: radioPicker]){
    id myArrayElement = [radioList objectAtIndex:row];
    NSString *title = myArrayElement; 
    NSLog(@"title to fill radio:%@", title); 
    return title;
  }


 }

// tell the picker the width of each row for a given component
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
int sectionWidth = 200;

   return sectionWidth;
 }

Essentially what seems to be happening is on the 2nd creation of the ‘RadioButton’ ListPicker, the first creation loses the tag ‘radioPicker’ and the line

if([pickerView isEqual: radioPicker]){ 

fails. So all of the data is pushed into the second(and latest) creation. But I don’t know how to have this not happen. Any ideas would be great.

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-28T20:51:48+00:00Added an answer on May 28, 2026 at 8:51 pm

    The issue is that you have a single instance variable, radioPicker. It’s fine to have two UIPickerViews and be the delegate of both. However, you need to base the delegate methods on the passed-in value, not the (single) instance variable.

    There’s actually no need to have radioPicker. Once you send addSubview:, just autorelease the view (unless you’re using ARC).

    In order to distinguish the views, you might want to set the tag property, and use that in things like the titleForRow: delegate method.

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

Sidebar

Related Questions

After writing code to populate textboxes from an object, such as: txtFirstName.Text = customer.FirstName;
I frequently find myself writing code like this: List<int> list = new List<int> {
I'm writing code that looks similar to this: public IEnumerable<T> Unfold<T>(this T seed) {
I'm writing code like this, doing a little quick and dirty timing: var sw
I am trying to send email programmatically... I have this line of code: _mail.AddAttachmentData(nsd,text/plain,
I'm writing code to programmatically run git commands and learning git at the same
I would like to find a way to programmatically (i.e. by writing code) find
When writing code do you consciously program defensively to ensure high program quality and
While writing code in a file that would comprise of PHP, HTML, CSS &
While writing code, it is pretty common to request a page with an appended

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.