Pregunta

Tengo una aplicación que usa un UITABBarController, y tengo otra vista que necesita deslizar desde detrás de los controles de la barra de pestañas, pero frente al contenido de la barra de pestaña. Si eso no está claro, imagine un anuncio que se desliza en una aplicación con pestañas que aparece frente a todo, excepto los botones de la barra de pestaña.

Hasta ahora tengo un código que se parece a esto, pero estoy dispuesto a cambiarlo si hay una mejor manera de hacer esto ...

tabBarController.viewControllers = [NSArray arrayWithObjects:locationNavController, emergencyNavController, finderNavController, newsNavController, nil]; 

aboutView = [[AboutView alloc] initWithFrame:CGRectMake(0, window.frame.size.height - tabBarController.tabBar.frame.size.height - 37 ,
                                                        320, window.frame.size.height - tabBarController.tabBar.frame.size.height)];


[window addSubview:tabBarController.view];    // adds the tab bar's view property to the window
[window addSubview:aboutView]; // this is the view that slides in
[window makeKeyAndVisible];

Actualmente se acerca a una subclase de UIView y se sienta en su posición inicial en la parte inferior, pero oculta el TabBarController. ¿Cómo puedo cambiar esto para dejar que las pestañas estén en la cima, pero aún así tengo la vista del otro frente al otro contenido?

¿Fue útil?

Solución

Debe agregar la vista sobre la vista como una subvisión de la vista en el controlador de vista actualmente activo en el UableBarController. Puede acceder a esa vista a través del SelectedViewController propiedad.

Puede agregar código a su implementación de View para animar la vista cuando aparezca.

Hago algo como esto en una vista emergente que quiero aparecer debajo de los controles de la barra de pestañas. Puede agregar algún código al didmovetosuperview Mensaje en la implementación de Upbers View:

- (void)didMoveToSuperview
{
    CGRect currentFrame = self.frame;

    // animate the frame ... this just moves the view up a 10 pixels. You will want to
    // slide the view all the way to the top
    CGRect targetFrame = CGRectOffset(currentFrame, 0, -10);

    // start the animation block and set the offset
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5]; // animation duration in seconds
    [UIView setAnimationDelegate:self];

    self.frame = targetFrame;

    [UIView commitAnimations];  
}

Entonces, cuando se agrega una vista de vista a la vista del controlador de vista seleccionado, se anima automáticamente.

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