2010-03-31 55 views
-1

我试图从屏幕底部(在标签栏的顶部)有一个UIPickerView幻灯片,但似乎无法让它显示出来。实际的动画代码来自Apple的示例代码项目之一(DateCell)。我从标签栏控制器下的第一个视图控制器(FirstViewController.m)调用此代码。通过UITabBarController添加UIPickerView

- (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)什么也没有发生一个的UIBarButtonItem这个动作火灾。任何人都可以请提供一些建议?

回答

0

原来我已经错过了UIPickerView已经在界面生成器中定义的非常重要的事实......在这样做后,连接插座一切正常!