iphone - UIViewController 推送和弹出问题

标签 iphone ios release dealloc pushviewcontroller

我遇到了推送和弹出 UIViewController 的问题。我有两个 UIViewController,分别为 AB

我编写了一个IBAction,其中我从A推送到B,例如,

B *bView=[[B alloc] initWithNibName:@"B" bundle:nil];
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:0.7];
[self.navigationController pushViewController:bView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

[bView release]; //Problem is here, If I comment this line, it works fine! else it crashes after my some transitions from A [push] B, B [pop] A.

现在在 B 中,我编写了一个 IBAction 来弹出到 A,如下所示

[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];

我还从 B 调用了[super dealloc]

-(void) dealloc
{
   [super dealloc];
}

如果我不释放bView,它不会调用dealloc,并且可能会产生内存问题。

这个问题是因为我应用了动画吗?

我尝试了所有其他方法,例如 autorelease、set bView=nil; 等,但这些对我不起作用!

任何帮助,建议!

最佳答案

尝试在动画完成 block 内释放bView

您可以使用旧样式+ setAnimationDidStopSelector: 或者如果您不需要支持iOS4之前的设备,您可以使用动画 block animateWithDuration:delay:options:animations:completion:

关于iphone - UIViewController 推送和弹出问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11256796/

相关文章:

iphone - 我是否需要注册 iOS 开发者计划才能分发我的应用程序?

ios - 在 didFinishLaunchingWithOptions 结束之前是否调用过 applicationWillResignActive?

go - goreleaser仅在GitHub上生成变更日志

build - 跨不同的 TeamCity 实例触发构建

ios - UISearchBar 将状态栏颜色更改为白色

iphone - 核心数据获取本周的数据

ios - SDK ios6 libxml2 预期为 ';'

ios - CloudKit "Couldn' t 仅在设备上获取签名证书

java - Spring 芯。默认@Bean 销毁方法

iphone - 在应用程序购买中:应用程序处于事件状态,并且仍显示[环境:沙箱]