Pregunta

Estoy tratando de tener una diapositiva UIPickerView de la parte inferior de la pantalla (en la parte superior de una barra de pestañas), pero parece que no puede conseguir que se presentó. El código real para la animación viene de uno de los proyectos de código de ejemplo de Apple (DateCell). Voy a llamar a este código del controlador primera vista (FirstViewController.m) bajo el control barra de pestañas.

- (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;
}}

Siempre que esta incendios de acción a través de un UIBarButtonItem que vive en un UINavigationBar (que es todo bajo la FirstViewController) no pasa nada. Puede alguien por favor ofrecen algunos consejos?

¿Fue útil?

Solución

Resulta que me había pasado por alto el hecho muy importante que el UIPickerView había sido definido en el Interface Builder, así ... después de hacer eso y la conexión de la salida de todo lo que está trabajando!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top