Pergunta

Eu quero remover o subexibição atual (adicionado atIndex: 0). Do meu controlador de vista raiz e insira uma nova visão em seu lugar

Atualmente eu só pode encontrar trechos de código que mostram que descarregam um vista usando removeFromSuperView, que exige que você sabe o que viewcontrollers vista é carregado no momento.

A única outra coisa a notar é que eu tenho um outro subexibição inserido nas rootcontrollers ver que eu não quero descarregado. Então o código que remove toda e qualquer subviews não é adequada

Obrigado,

m

if(self.firstscr == nil)
    {
        firstscreen *f = [[firstscreen alloc] initWithNibName:@"firstscreenview" bundle:nil];
        self.firstscr = f;
        [f release];
    }

    ///This is my attempt at getting to the currently loaded view :P
  [[self.view subviews atIndex:0].view removeFromSuperView];


    [self.view insertSubview:firstscr.view atIndex:0];
Foi útil?

Solução

Aqui está como fazê-lo (i percebi isso, Yey me!)

if(self.firstscr == nil)
    {
        firstscreen *f = [[firstscreen alloc] initWithNibName:@"firstscreenview" bundle:nil];
        self.firstscr = f;
        [f release];
    }

    //Remove whatever view is currently loaded at index 0, this index is only to be used by "page" views
    UIView *v = [self.view.subviews objectAtIndex:0];
    [v removeFromSuperview];


    [self.view insertSubview:firstscr.view atIndex:0];
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top