gpt4 book ai didi

ios - 制作动画时获取 EXC_BAD_ACCESS 访问权限

转载 作者:行者123 更新时间:2023-11-29 04:37:44 25 4
gpt4 key购买 nike

我正在制作动画,因此当您从第一个屏幕单击“我的帐户”按钮时,它会将您导航到帐户 View

- (void)pushToAccount
{
AccountViewController *controller = [[AccountViewController alloc] initWithNibName:@"AccountViewController" bundle:nil];
//[self.navigationController pushViewController:controller animated:NO];

[UIView beginAnimations: @"Showinfo"context: nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.view addSubview:controller.view];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO];
[UIView commitAnimations];

}

但是,每当我单击帐户 View Controller (其中包含一些按钮和 ImageView )时,我的程序就会崩溃,因为它在主类中显示 EXC_BAD_ACCESS

请就这个问题给我建议...

最佳答案

您的 View Controller 正在尝试通过添加另一个 View Controller 的 View 作为当前 View 的 subview 来对转换进行动画处理。这在很多方面都是有问题的。值得注意的是,您没有对新 View Controller 本身执行任何操作...如果这是一个 ARC 项目,它将由您发布。

如果您只想从一个 View Controller 转换到另一个 View Controller ,通常应该执行标准的 pushViewController:animated:presentModalViewController:animated:。看起来你以前经常做前者。为什么用当前代码替换它?

如果您能告诉我们您想要做什么、为什么不使用标准过渡,也许我们可以为您提供进一步帮助。

更新:

如果您不喜欢默认动画,而是希望在过渡中使用一些自定义动画,您可以执行以下操作:

CustomAnimationViewController *yourNewViewController = [[CustomAnimationViewController alloc] initWithNibName:@"CustomAnimationView" bundle:nil];

[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:yourNewViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

// if you're using ARC, you don't need this following release, but if you're not using ARC, remember to release it

// [yourNewViewController release];

更新2:

并且,预测逻辑后续问题,如何以动画方式关闭新 View Controller ,例如,您可能有一个“完成”按钮来调用如下方法:

- (IBAction)doneButton:(id)sender 
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
}

关于ios - 制作动画时获取 EXC_BAD_ACCESS 访问权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10850717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com