【问题标题】:How to remove previous ViewController?如何删除以前的 ViewController?
【发布时间】:2011-07-18 16:07:23
【问题描述】:

寻求帮助。

我的项目: 我为孩子们做一本书。 每个页面都是一个自定义的 ViewController。 在每个页面上,我都有一个用于下一页和上一页的按钮。 当按下 NextPage-Button 时,我“切换”/在 AppDelegate 中添加一个 ViewController,如下所示:

- (void)goToNextPage2 {
self.view2 = [[ViewController2 alloc] init];
view2.view.frame = CGRectMake(769, 0, 768, 1024);
[window addSubview:view2.view];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];
view2.view.frame = CGRectMake(0, 0, 768, 1024);
[UIView commitAnimations];
}

如何以及在哪里删除以前的 Viewcontroller? 在这种情况下,它将是 ViewController1。 有什么想法吗?

提前致谢 木板

【问题讨论】:

  • 为什么要“删除”之前的视图?

标签: objective-c xcode uiview viewcontroller


【解决方案1】:

您没有提供太多信息...
无论如何,这可能会有所帮助。

在您的动画代码中:

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

并添加它以删除 ViewController:

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
    [self.view1.view removeFromSuperview];
    self.view1 = nil;
}

【讨论】:

  • 我的声望不够,对不起。但当我有足够的时候,我会的。承诺!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-10
  • 1970-01-01
  • 1970-01-01
  • 2017-03-11
  • 1970-01-01
相关资源
最近更新 更多