-1

画面の下部 (タブ バーの上部) から UIPickerView をスライドさせようとしていますが、表示されないようです。アニメーションの実際のコードは、Apple のサンプル コード プロジェクト (DateCell) の 1 つから来ています。タブ バー コントローラーの下にある最初のビュー コントローラー (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 の下にある) に存在する UIBarButtonItem を介して起動するたびに、何も起こりません。誰かアドバイスをお願いできますか?

4

1 に答える 1

0

UIPickerView が Interface Builder でも定義されているという非常に重要な事実を見逃していたことが判明しました...それを実行してアウトレットに接続した後、すべてが機能しています!

于 2010-03-31T21:00:15.180 に答える