【发布时间】:2011-04-28 11:13:34
【问题描述】:
我的应用在模拟器中运行了一段时间,但几次触摸后,它崩溃并烧毁。
这里是代码
-(IBAction)extraCrisp:(id)sender
{
myViewController *myView = [[myViewController alloc]
initWithNibName:@"myViewController"
bundle:nil];
// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];
UIView *newView = myView.view;
// remove the current view and replace with myView1
[currentView removeFromSuperview];
[theWindow addSubview:newView];
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
[myView release];
}
那么,我在这里做错了什么?任何帮助都会受到高度赞扬。谢谢
【问题讨论】:
-
你想用这段代码做什么,首先显示一个视图,然后在一个按钮上单击带有过渡动画的第二个视图,对吧?
-
你有我们的崩溃日志吗?
-
@Krishnabhadra 是的,这正是我想要做的。
-
我收到了 EXC_BAD_ACCESS,对不起,有点初学者......你需要什么样的崩溃日志?或者在哪里可以找到......再次,初学者的东西。仍然在学习。非常感谢。
标签: ios objective-c memory-management memory-leaks