我想有来自屏幕的底部一个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;
}}

每当经由的UIBarButtonItem这个动作的火灾,生活在一个UINavigationBar的(这是所有下FirstViewController)没有反应。任何人都可以请提供一些建议吗?

有帮助吗?

解决方案

原来我已经错过了UIPickerView曾在Interface Builder定义,以及...这样做,并连接了出口一切工作后,非常重要的事实!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top