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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:13:00+00:00 2026-05-18T04:13:00+00:00

I am trying to implement a custom picker. It has 3 components. Now, I

  • 0

I am trying to implement a custom picker. It has 3 components. Now, I want to gray out some values in the second component based on the first component value selected. I have referred to many sites and tried googling out to disable the values.(To be precise, something like the uidatepicker where if we select feb, 29 and 30 will be grayed. But i am trying to do it in custom picker implementing my own contents). Could some one help me how to go about for disabling the values in custom picker? I tried using the function

[myPickerView selectRow:27 inComponent:1 animated:NO];

based on the if conditions also. It directly goes to the value, but doesn’t gray out the unnecessary values.

My code:

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
 NSString *returnStr = @"";

 // note: custom picker doesn't care about titles, it uses custom views
 if (pickerView == myPickerView)
 {
  if (component == 0)
  {
   returnStr = [pickerViewArray objectAtIndex:row];
  }
  else if(component ==1)
  {
   returnStr = [pickerViewArray1 objectAtIndex:row];
  }
  else
  {
   returnStr = [pickerViewArray2 objectAtIndex:row];
  }
 }

 return returnStr;
}

- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
 CGFloat componentWidth = 0.0;

 if (component == 0)
 {
  componentWidth = 140.0;
 }// first column size is wider to hold names
 else if(component ==1)
 {
  componentWidth = 40.0;
 }// second column is narrower to show numbers
 else if(component == 2)
 {
  componentWidth = 100;
 }

 return componentWidth;
}

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
 return 40.0;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
 //return [pickerViewArray count];
 if (component == 0)
 {
  return [pickerViewArray count];
 }// first column size is wider to hold names
 else if(component ==1)
 {
  return [pickerViewArray1 count];
 }

 else
 {
  return [pickerViewArray2 count];
 }


}

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

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
 if (pickerView == myPickerView) // don't show selection for the custom picker
 {
  // report the selection to the UI label


  label.text = [NSString stringWithFormat:@"%@  %@  %@",
      [pickerViewArray objectAtIndex:[pickerView selectedRowInComponent:0]],
      [pickerViewArray1 objectAtIndex:[pickerView selectedRowInComponent:1]],[pickerViewArray2 objectAtIndex:[pickerView selectedRowInComponent:2]]];
 }
}
  • 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-18T04:13:01+00:00Added an answer on May 18, 2026 at 4:13 am

    I haven’t tried it, but there is -pickerView:viewForRow:forComponent:reusingView:. Its documentation says:

    If the previously used view (the view parameter) is adequate, return that. If you return a different view, the previously used view is released. The picker view centers the returned view in the rectangle for row.

    so if I undertstand corectly, you could take that passed in view, change it (grey out) and return it.

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

Sidebar

Related Questions

I'm trying to implement a DataGrid in ASP.NET, and want to achieve custom paging
im trying to implement a custom error page, what i want to be able
I'm trying to implement a view controller for a custom NSOpenGLView based view (this
I am trying to implement a custom view, for which I want to be
I am trying to implement a custom broken image icon to appear if I
I'm trying to implement the Media Player custom field control described in this MSDN
I am trying to implement Custom Error handling via Action Filter Attributes. My code
I'm trying to implement a custom control in C# and I need to get
I am trying to implement a custom profile class in C# that inherits System.Web.Profile.ProfileBase.
I'm trying to implement a custom TableRenderer as described in this tutorial . I'd

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.