Barra de tabulação na rota do controlador de exibição dividida - Como se conectar à vista de detalhes?

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

  •  15-11-2019
  •  | 
  •  

Pergunta

Trabalhando no meu primeiro projeto do iPad e depois de muitos falsos iniciamos, tenho uma interface básica que estou feliz com isso consiste em um controlador de exibição dividida com uma barra de 4 guia na parte inferior da raiz / poppover.

Eu tenho 4 controladores de visualização diferentes para cada uma das 4 guias. Três dessas tabelas contêm, o quarto contém meus sliders & switches de configurações. Tudo isso funciona bem no retrato ou na paisagem.

O desafio que estou enfrentando é como impulsionar a visualização detalhada dessas várias guias. Eu não necessariamente preciso de várias visualizações de detalhes, pois todas as 3 tabelas estarão referenciando os mesmos dados, apenas classificados de forma diferente. Para que eles pudessem se conectar à mesma visualização detalhada.

Eu não encontrei outros exemplos de barras de abas sendo usadas como esta, mas parece que a solução perfeita para o meu aplicativo.

Como faço para estabelecer uma conexão para que, quando seleciono uma célula de tabela, as informações detalhadas são exibidas na exibição detalhada? A barra da guia foi adicionada à vista da raiz no IB. Devo adicioná-lo programaticamente?

Alguém tem um projeto de exemplo onde você tem isso funcionar?

Obrigado!

Foi útil?

Solução

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top