Iphone 在UITabBarController上添加UIPickerView

Iphone 在UITabBarController上添加UIPickerView,iphone,objective-c,uipickerview,addsubview,Iphone,Objective C,Uipickerview,Addsubview,我试图从屏幕底部(选项卡栏顶部)播放UIPickerView幻灯片,但似乎无法显示。动画的实际代码来自苹果的一个示例代码项目(DateCell)。我从选项卡栏控制器下的第一个视图控制器(FirstViewController.m)调用此代码 - (IBAction)showModePicker:(id)sender { if (self.modePicker.superview == nil) { [self.view.window addSubview:self.modePicker]

我试图从屏幕底部(选项卡栏顶部)播放UIPickerView幻灯片,但似乎无法显示。动画的实际代码来自苹果的一个示例代码项目(DateCell)。我从选项卡栏控制器下的第一个视图控制器(FirstViewController.m)调用此代码

- (IBAction)showModePicker:(id)sender {
if (self.modePicker.superview == nil) {
    [self.view.window addSubview:self.modePicker];

    // size up the picker view to our screen and compute the start/end frame origin for our slide up animation
    //
    // compute the start frame
    CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
    CGSize pickerSize = [self.modePicker sizeThatFits:CGSizeZero];
    CGRect startRect = CGRectMake(0.0, screenRect.origin.y + screenRect.size.height, pickerSize.width, pickerSize.height);
    self.modePicker.frame = 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.modePicker.frame = pickerRect;

    // shrink the vertical size to make room for the picker
    CGRect newFrame = self.view.frame;
    newFrame.size.height -= self.modePicker.frame.size.height;
    self.view.frame = newFrame;
    [UIView commitAnimations];

    // add the "Done" button to the nav bar
    self.navigationItem.rightBarButtonItem = self.doneButton;
}}

每当此操作通过位于UINavigationBar(都在FirstViewController下)中的uiBarButtonim触发时,都不会发生任何事情。有人能给我一些建议吗?

我发现我忽略了一个非常重要的事实,即UIPickerView也在Interface Builder中定义过。。。完成此操作并连接插座后,一切正常