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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:16:57+00:00 2026-05-23T18:16:57+00:00

I have a UIPickerView that animates up and down in a UITableViewController. I adapted

  • 0

I have a UIPickerView that animates up and down in a UITableViewController. I adapted an example from apple (DateCell). The UIPickerView is created programmatically, no nib files.

In Portrait mode everything looks nice. When I rotate the simulator (I not testing on the device), the UITableView rotates well, but the picker remains were it was. I read tons of threads about that topic and many developers seem to have problems with pickers behaving weird in landscape mode but at least their pickers rotate. I made a subclass of UIPickerView as described in this link: http://www.llamagraphics.com/developer/using-uidatepicker-landscape-mode, but it didn’t help for the rotation issue.

I tried to rotate the picker with a transform but it looked very weird, like broken.

I’m suspecting that the problem is that I’m using the picker inside of a UITableViewController, and so I add it as a subview of self.view.window. If I try to add the picker as a subview of self.view, only a white frame (without any picker) appears.

Any suggestions?

The initialization code in the UITableViewController subclass:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.pickerView.superview == nil)
    {
        //Initialization code 
        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
        CGRect initFrame = orientation == UIInterfaceOrientationPortrait ? CGRectMake(0, 0, 320, 200) : CGRectMake(0, 0, 480, 160);

        self.pickerView = [[RotatingUIPickerView alloc] initWithFrame:initFrame];
        [self.pickerView setDelegate:self];
        [self.pickerView setShowsSelectionIndicator:YES];
        [self.pickerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];

        [self.view.window addSubview:self.pickerView];

        // compute the start frame
        CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
        CGSize pickerSize = [self.pickerView sizeThatFits:CGSizeZero];
        CGRect startRect = CGRectMake(0.0,
                                      screenRect.origin.y + screenRect.size.height,
                                      pickerSize.width, pickerSize.height);

        [self.pickerView setFrame:startRect];

        // compute the end frame
        CGRect pickerRect = CGRectMake(0.0,
                                       screenRect.origin.y + screenRect.size.height - pickerSize.height,
                                       pickerSize.width,
                                       pickerSize.height);

        // start the slide up animation
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];

        // we need to perform some post operations after the animation is complete
        [UIView setAnimationDelegate:self];

        [self.pickerView setFrame:pickerRect];

        [UIView commitAnimations];
    }
}

Implementation of UIPicker subclass as described on the link above:

- (id)initWithFrame:(CGRect)frame 
{
    if (self == [super initWithFrame:frame]) 
    {
        for (UIView * subview in self.subviews) 
        {
            [subview setFrame:self.bounds];
        }
    }
    return self;
}

- (id) initWithCoder:(NSCoder *)aDecoder 
{
    if (self == [super initWithCoder: aDecoder]) 
    {
        for (UIView * subview in self.subviews) 
        {
            [subview setFrame:self.bounds];
        }
    }
    return self;
}
  • 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-23T18:16:58+00:00Added an answer on May 23, 2026 at 6:16 pm

    By executing:

     [self.view.window addSubview:self.pickerView];
    

    you are adding pickerView as a subview of your UIWindow. I don’t know how the main UIWindow can be rotated, if it can be.

    When you are adding pickerView to the view

     [self.view addSubview:self.pickerView];
    

    you get problems due to the view being a UITableView.

    What I suggest is adding pickerView to some intermediate UIView, added as subview to UIWindow and to which you add the UITableView. This intermediate UIView would also have a UIViewController associated to it so that shouldAutorotateToInterfaceOrientation can return the proper value to have auto rotation working.

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

Sidebar

Related Questions

I have a UIPickerView that pops up from the bottom of the IPhone's screen
I have a UIPickerView as subview in a UITableViewController, which I want to slide
I'm trying to have a UIPickerView slide from the bottom of the screen (over
Does anyone have a basic example to display a UIPickerView when a UITextField was
I have my view that contains the UIPickerView... I tried to make this code:
I have a UIPickerView that gets faded out to 20% alpha when not in
I have a UIPickerView object that has five rows that a user can select.
basically i have parsed some data from XML into a NSMutableArray that is shared
I have an iPhone application with a UIPickerView with 6 components that displays numbers
I currently have a UIPickerView in my app. There is a text box that

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.