【发布时间】:2011-10-26 05:29:44
【问题描述】:
我正在尝试添加一个子视图,然后还删除以前的视图。
这是我的代码的样子:
HowToPlay *LetsPlay = [[HowToPlay alloc] initWithNibName:@"HowToPlay" bundle:nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:[self view]
cache:YES];
[UIView commitAnimations];
MainViewController *ma = [[MainViewController alloc]init];
[ma.view removeFromSuperview];
[self.view addSubview:LetsPlay.view];
Mainviewcontroller 是它当前所在的视图。我希望它关闭该视图,然后继续添加新视图 LetsPlay。
这段代码运行,它加载了一个新视图,但是当我从 LetsPlay 加载另一个视图时,我可以看到 mainviewcontroller 仍在它后面运行。我想永久关闭它。
我什至不确定我是否正确地这样做,所以如果我不能,请给我一个如何正确地做的例子。
谢谢:)
【问题讨论】:
标签: objective-c ios view subview