質問

ルートビューコントローラから現在のサブビュー(atIndex:0を追加)を削除し、その場所に新しいビューを挿入します。

現在、removeFromSuperViewを使用してビューのアンロードを示すコードスニペットのみを見つけることができます。これには、現在読み込まれているviewcontrollersビューを知る必要があります。

他に注意すべきことは、ルートコントローラービューに別のサブビューが挿入されていることです。したがって、すべてのサブビューを削除するコードは適切ではありません

ありがとう、

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];
役に立ちましたか?

解決

これを行う方法は次のとおりです(わかりました、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];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top