objective-c - 我的应用程序在 CGRectIntersectsRect 上崩溃

标签 objective-c ios cocoa-touch crash

我的应用程序在 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];
}

最佳答案

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

如果这样做的话它会在哪里崩溃

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

而不是

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

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

关于objective-c - 我的应用程序在 CGRectIntersectsRect 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8603545/

相关文章:

iOS 配件 SDK - 3.5mm 插孔控制

ios - 接收方向更改通知时 StatusBar 方向错误

iphone - 核心文字并在iOS上复制并粘贴

ios - 通过 CGAffineTransform 缩放 super View 后 subview 错位

ios - 与NSInteger的关联引用

iphone - 我如何让图层的框架根据其超层的框架或 View 的框架自动调整大小?

ios - 在 ios 中用不同的颜色重新动画渐变背景

iphone - 使用sqlite进行iPhone本地化?

ios - 使用 Objective-C/C 查找 DST(夏令时)时间戳?

ios - SKMaps 关注者用户位置 离线模式 iOS 8 beta