我的应用程序在 CGRectIntersectsRect 上崩溃

发布于 12-22 06:16 字数 470 浏览 2 评论 0原文

我的应用程序在 CGRectIntersectsRect 上崩溃,我不知道该怎么办。
这是我的代码:

if(CGRectIntersectsRect(player.frame,enemy.frame)) 
{
    loseViewController *controller = [[loseViewController alloc] initWithNibName:@"loseView" bundle:nil];                                        

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:controller animated:NO];   
    [controller release];
}

My app crashes on CGRectIntersectsRect and I dont know what to do.
Here is my code :

if(CGRectIntersectsRect(player.frame,enemy.frame)) 
{
    loseViewController *controller = [[loseViewController alloc] initWithNibName:@"loseView" bundle:nil];                                        

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:controller animated:NO];   
    [controller release];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

像极了他2024-12-29 06:16:04

扩展 @Vince 的评论(我不确定为什么它不是答案!)。 。 。 。

如果您这样做,它会在哪里崩溃,

CGRect playerRect = player.frame;
CGRect enemyRect = enemy.frame;
if (CGRectIntersectsRect(playerRect, enemyRect)) {

而不是

if(CGRectIntersectsRect(player.frame,enemy.frame)) {

That 应该告诉您哪个(或两个)对象已被释放。

Expanding on @Vince's comment (I'm not sure why it wasn't an answer!) . . . .

Where does it crash if you do

CGRect playerRect = player.frame;
CGRect enemyRect = enemy.frame;
if (CGRectIntersectsRect(playerRect, enemyRect)) {

instead of

if(CGRectIntersectsRect(player.frame,enemy.frame)) {

That should tell you which (or both) object has been deallocated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文