簡體   English   中英

iPhone版本內部版本與調試版本不同

[英]iPhone release build not functioning the same as debug build

我的項目工程使用的調試版本時,我希望它在iPhone模擬器和iPhone本身的兩種方式。 但是,當我將其更改為發行版時,它可以在iPhone模擬器上運行,但不能在設備上運行。 我正在嘗試使用計時器為屏幕上的球設置動畫,並且如果球與屏幕邊緣發生碰撞,則該球應從側面彈起。 這對於調試版本運行良好,但發行版本僅適用於模擬器,而不適用於設備。 在釋放版本中,球甚至不會在設備上移動。

我感覺這與從調試切換到發布版本時更改的優化級別有關。 如果是這樣,如何更改代碼以更好地適應優化級別?

使用initWithNibName:調用視圖控制器,其中包含:

CGRect ballRect = CGRectMake(133, 424, 55, 56); 
newBall = [[Ball alloc] initWithFrame: ballRect];
[self.view addSubview: newBall];
[self setImage: [UIImage imageNamed: @"Red.png"]];

Ball * newBall在接口文件中聲明。 球在屏幕上正確顯示,並且所有構建中的圖像均正確。

當用戶點擊屏幕時,將調用移動球的計時器:

-(void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event{
    touch = [touches anyObject];
    touchPoint = [touch locationInView: self.view];
    dx = touchPoint.x - newBall.center.x;
    dy = touchPoint.y - newBall.center.y;
    newBallTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0/50.0 target: self selector: @selector(moveBall) userInfo: nil repeats: YES];
}

CGPoint touchPoint,UITouch * touch,float dx,float dy和NSTimer * newBallTimer也已在接口文件中聲明。

這是我用於移動球和檢測碰撞的代碼:

-(void) moveBall
{       
    newBall.center = CGPointMake( newBall.center.x + dx, newBall.center.y + dy );

    // left boundary
    if( newBall.frame.origin.x <= 20 )
    {
        dx = abs(dx);
    }   
    else if( newBall.center.x >= 280 )  
    {
        dx = -abs(dx);
    }
}       

在設備上的釋放版本上,球不會移動。 相反,它似乎已發送到屏幕底部並停留在該位置。

任何建議/解決方案/思想的高度贊賞。 提前致謝!

您如何將發行版構建到設備上? 還是您說的是Ad hoc版本?

在這兩種情況下,您是否都有任何#define或#ifdef代碼塊在進行發行版本構建時可能被注釋掉了?

另一種可能性是在NSAssert中執行實際邏輯,然后在發布版本中關閉斷言。 當您關閉斷言時,該斷言中的任何代碼都不會被調用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM