1

夏天,我在 iPhone 4 上为 iOS 4.3 开发了一个应用程序,一切运行良好。在我重新安置工作时,我把那个项目搁置了。随着 iOS 5 的发布,我将 Xcode 和 iOS SDK 分别更新到了 4.2 和 5.0,我还购买了运行 5.0 的新 iPod Touch 进​​行开发。

我的应用程序仍然可以在 iPhone 4.3 模拟器中运行(不幸的是,我不再需要在 iPhone 4 上进行测试),但它在 iPhone 5.0 模拟器和 iPod Touch 上总是崩溃。

当我尝试加载子视图并转到主视图并说它与 SIGABRT 一起崩溃时,就会发生错误。以下是发生崩溃的代码段:

-(IBAction) showView:(id) sender{   
    if (self.tViewController == nil) {
        self.tViewController = [[TViewController alloc] init];
    }

    [self.navigationController pushViewController:tViewController animated:YES];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.75];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
                         forView:self.view
                         cache:YES];

    [self.view addSubview:tViewController.view];
    [UIView commitAnimations];
}

当我穿过并到达这条线时:

[self.view addSubview:tViewController.view];

它崩溃了,然后跳转到 main.m:

int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}

并显示在此行收到“SIGABRT”:

int retVal = UIApplicationMain(argc, argv, nil, nil);

我已经读到该错误来自两次发布的内容。但是在我的“showView”功能中,我看不出我可以在哪里做到这一点。除非 addSubview 方法做了我不知道的事情。

另外,为什么这个错误发生在 5.0 而不是 4.3?

任何帮助表示赞赏。

4

1 回答 1

1
-(IBAction) showView:(id) sender{   
    if (self.tViewController == nil) {
        self.tViewController = [[TViewController alloc] init];
    }

    [self.navigationController pushViewController:tViewController animated:YES];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.75];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
                     forView:self.view
                     cache:YES];

    [self.view addSubview:tViewController.view];
    [UIView commitAnimations];
}

您已经使用此视图推送此视图,[self.navigationController pushViewController:tViewController animated:YES]那么为什么要使用[self.view addSubview:tViewController.view]删除这行代码将其添加到主视图。

于 2011-10-17T05:10:17.927 回答