【发布时间】:2012-02-14 22:32:12
【问题描述】:
我正在使用以下方法切换视图:
FirstView.m
-(IBAction)showAnimal:(UIButton *)sender{
NSString *digit = [NSString stringWithFormat:@"%d",[sender tag]];
//NSString *digit = [[sender titleLabel] text];
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.indexOfImage = digit;
Animal *myAnimal = [[Animal alloc]
initWithNibName:@"Animal" bundle:nil];
[UIView beginAnimations:@"flipView" context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.view cache:YES];
[UIView commitAnimations];
//[self presentModalViewController:myAnimal animated:YES];
myAnimal.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.view addSubview:myAnimal.view];
self.view.bounds = myAnimal.view.bounds;
}
第二视图的方法 Animal.m
-(IBAction)backToFront:(id)sender{
[UIView beginAnimations:@"flipView" context:nil];
[UIView setAnimationDuration:1.2];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:self.view.superview cache:YES];
[self.view removeFromSuperview];
[UIView commitAnimations];
}
我多次使用此代码,直到现在它始终可以正常工作。 每次我想切换回来时,我的应用程序都会崩溃。所以 Animal 视图上的方法崩溃了。奇怪的是我得到了一个奇怪的错误。我有一个截图。
请帮忙!
【问题讨论】:
标签: iphone ios xcode uiviewcontroller