2010-03-31 56 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已經在界面生成器中定義的非常重要的事實......在這樣做後,連接插座一切正常!