【发布时间】:2009-03-01 19:09:43
【问题描述】:
我想从我的根视图控制器中删除当前的子视图(添加 atIndex:0)并在其位置插入一个新视图。
目前我只能找到代码 sn-ps 显示使用 removeFromSuperView 卸载视图,这需要您知道当前加载的 viewcontrollers 视图。
唯一需要注意的是,我在 rootcontrollers 视图中插入了另一个子视图,我不想卸载它。所以删除所有子视图的代码是不够的
谢谢,
米
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];
【问题讨论】:
标签: iphone cocoa-touch