2012-09-11 26 views
0

我在我的應用程序中使用corelocation,它根據需要檢索緯度/經度,但當我「退」出該頁面([self dismissModalViewControllerAnimated:YES];)應用程序崩潰。Corelocation崩潰

我沒有得到任何錯誤,只能假設我不能正常退出更新位置?

任何幫助?

感謝

+0

當它崩潰時它會給出什麼信息? – jrtc27

+0

沒有給出消息,只是崩潰。 –

+0

崩潰日誌在組織者中說什麼? – jrtc27

回答

0

你的問題是相當模糊的,但我估計你指的是你CLLocationManager的代表。您的頁面被取消分配,位置管理器失去它的委託並且位置管理器嘗試訪問它的委託時應用程序崩潰。

你應該收拾妥當位置管理。

在-dealloc,在 - 可能一個UIViewController設置類似(這僅僅是一個開始):

- (void) dealloc { 
    //todo: stop updating/release the location manager too 
    [self.locationManager setDelegate:nil]; 

    //there should be a lot more code here 

    [super dealloc]; 
} 

你應該適當地管理你的對象,尤其是你的位置管理器,雖然。您應該閱讀Apple的Delegates and Data Sources文檔和Apple的Memory Management guide