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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:51:18+00:00 2026-05-25T05:51:18+00:00

I have used Interface Builder in Xcode 4.02 to add two UIPickerViews in a

  • 0

I have used Interface Builder in Xcode 4.02 to add two UIPickerViews in a View. They are connected to the same delegate and datasource (UIViewController). In my .h file I have also declared UIPickerViews and connected them as reference outlets, as in many examples.
In viewForRow I use the same NSMutable data array of UILabels to return the appropriate values (this array was populated in viewDidLoad).

However, I find that no Label appears in both UIPickerViews at the same time. For example, when the app starts each UIPickerView should show elements 0, 1 and 2. viewForRow is invoked 3 times for each UIPickerView but only the view which invokes viewForRow second will display the first 3 rows. The other UIPickerView is blank. If I scroll the first view down to, say, the 6th element and then back to the first, the view will then show the first 3 elements but the second view (the one that did show the first 3 rows) now shows nothing. Specifically, no data array element will appear in both UIPickerViews at the same time.

Is this expected? Should each UIPickerView have its own backing array – if you’re using them? Aren’t all these returned views just pointers? It’s as if each array element can only be displayed (pointed to) at most once at any time.

If I use two separate data arrays then there appear to be no problems. But it does mean extra memory and extra coding.

Note: in viewForRow I have code to set the label’s size:

    UILabel *xx = (UILabel *)[self.array1 objectAtIndex:row];        
    CGSize rowSize = [thePickerView rowSizeForComponent:component];
    CGRect labelRect = CGRectMake (0, 0, rowSize.width, rowSize.height);
    [xx setFrame:labelRect];

The values set here do not change even when the row later appears to be blank.

  • 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-25T05:51:18+00:00Added an answer on May 25, 2026 at 5:51 am

    Multiple picker views can share the same data source but a view (UILabel in this case) can only have one superview.

    You cannot use the same labels in both pickers and there’s probably little reason to store them in an array of your own anyway. A better approach would be to create a separate label in the viewForRow method and have just an array with the labels’ content (e.g. an NSString).

    In your current implementation, when you return the label, the picker adds it to its own view hierarchy which implicitly removes it from any view it was in before (your other picker).

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

Sidebar

Related Questions

I have two View Controllers: TableViewController (which is used as a modal view controller)
I have a UITableView inside UiViewController. In the same screen, I also have two
I have a view that gets used in each of my CollectionView's items. I
I have a UIScrollView which content is designed with Interface Builder. It has a
i have two views 1st one is displaying list (uitableview used), user will select
In many iOS books and tutorials they demonstrate how in interface builder you can
I so far only have the interface builder layout I'm not clear on the
Can I get the objects created in Interface builder in xcode by program ?
So here is my problem: I have used a number of interfaces in my
I have a question with fluent interfaces. We have some objects that are used

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.