Barra de pestañas en la raíz del controlador Split View - ¿Cómo conectarse a la vista de detalle?

StackOverflow https://stackoverflow.com/questions/5055239

  •  15-11-2019
  •  | 
  •  

Pregunta

Trabajar en mi primer proyecto de iPad y después de muchos comienzos falsos Tengo una interfaz básica con la que estoy contento con eso consiste en un controlador de visión dividida con una barra de pestañas de 4 pestañas en la parte inferior de la raíz / popover.

Tengo 4 controladores de vista diferentes para cada una de las 4 pestañas. Tres de estos contienen tablas, el cuarto contiene mis ajustes deslizantes y conmutadores. Todo esto funciona bien en retrato o paisaje.

El desafío que enfrento es cómo conducir la vista detallada desde estas diversas pestañas. No necesariamente necesariamente necesita múltiples vistas detalladas, ya que las 3 tablas se harán referencia a los mismos datos, simplemente ordenados de manera diferente. Por lo que potencialmente podrían conectarse a la misma vista detalladamente.

No he encontrado ningún otro ejemplos de barras de pestañas que se usan así, pero parece que es la solución perfecta para mi aplicación.

¿Cómo establezco una conexión para que cuando seleccione una celda de tabla, la información de detalle se muestra en la vista detallada? La barra de pestañas se agregó a la vista raíz en IB. ¿Debo agregarlo programáticamente en su lugar?

¿Alguien tiene un proyecto de ejemplo en el que ha obtenido esto para trabajar?

¡Gracias!

¿Fue útil?

Solución

Don't get too caught up in the 'tabbar' piece of this. Consider how a simpler app would work: if you select a cell in the RootViewController, how would you notify the DetailViewController?

It won't be automatic. Most likely, you will have a dedicated connection from the RootViewController to the DetailViewController - and you will invoke some method on the DetailViewController from the RootViewController in something like the

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

method in the RootViewController. Indeed, this is how the template UISplitView iPad app is setup. There is an IBOutlet connection from the RootViewController to the DetailViewController.

As long as you manage the memory correctly (retain, release) - there should be no problem if each of your (root) view controllers (in the tab view) have a connection to the single DetailViewController. To keep the tab'd controllers from stepping on each other, you may wish to centralize the logic into a 'middleman' class. Maybe you want to clean something up just before ViewControllerB sorts the details that ViewControllerA just sorted ...

That part is up to you. Just note that there is no backend black magic going on such that a DetailViewController is automatically updated to show something based on a cell selected in any RootViewController.

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