iphone - 切换 View 在 xcode 中不起作用

标签 iphone ios xcode uiviewcontroller

我正在使用以下方法切换 View :

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 View 上的方法崩溃了。奇怪的是我得到了一个奇怪的错误。我有一张截图。

enter image description here

请帮忙!

最佳答案

EXC_BAD_ACCESS 通常在您处理释放对象(僵尸)时出现。转到产品 > 编辑方案 > 在环境变量区域中添加值为 yes 的 NSZombieEnabled ..这将在控制台中显示僵尸对象。

关于iphone - 切换 View 在 xcode 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9285208/

相关文章:

ios - Xcodes UI 测试 - 点击一个 x y 位置

iphone - 调用宏

ios - 如何使用参数执行选择器?

iphone - 在多个 ImageView 上滑动手指

iphone - 表格 View 图像应用程序中的内存警告 - 延迟下载

ios - 如何“预填充” GPUImage滤镜以加快加载时间

iphone - 如何在 iOS 上的应用程序之间共享值

objective-c - 在发布版本上创建自定义错误

iphone - 如何加入 iPad 和 iPhone 应用程序?

iphone - 为什么 UIWebView 不断检测电话号码?