2009-12-11 46 views
0

當我在設備發佈模式下運行此代碼時,它會在「[mapView setRegion:region animated:TRUE];」上繪製一個「SIGABRT」線。但是,我在調試模式或模擬器模式下都沒有遇到問題。發佈代碼的流程與調試不同嗎?

我是xcode的新手。我究竟做錯了什麼?

- (void)initUI { 
// add a map view in available area 
startupPage = [[CSNet alloc] init]; 
positionUpdatePage = [[CSNet alloc] init]; 
opponentsPage = [[CSNet alloc] init]; 
firePage = [[CSNet alloc] init]; 
checkinPage = [[CSNet alloc] init]; 
[self getStartup:FALSE]; 
UIImage *blueButton = [[UIImage imageNamed:@"blueButton.png"] stretchableImageWithLeftCapWidth:12.0f topCapHeight:0.0f]; 
UIImage *redButton = [[UIImage imageNamed:@"redButton.png"] stretchableImageWithLeftCapWidth:12.0f topCapHeight:0.0f]; 
UIImage *gpsImage = [UIImage imageNamed:@"gps_icon.png"]; 
[self initSounds]; 
[gpsButton setBackgroundImage:gpsImage forState:UIControlStateNormal]; 
[settingsButton setBackgroundImage:blueButton forState:UIControlStateNormal]; 
[joinButton setBackgroundImage:blueButton forState:UIControlStateNormal]; 
[fireButton setBackgroundImage:redButton forState:UIControlStateNormal]; 
[self UpdateIndicators]; 
MKCoordinateRegion region; 
region.span.latitudeDelta = [appDelegate.savedSpanLatitude floatValue]; 
region.center.latitude = [appDelegate.savedLatitude floatValue]; 
region.center.longitude = [appDelegate.savedLongitude floatValue]; 
mapHeight = self.view.frame.size.height; // - 50; 
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, mapHeight)]; 
// viewtouch catches events on map 
viewTouch = [[CSViewTouch alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, mapHeight)]; 
viewTouch.multipleTouchEnabled = TRUE; 
[self.view insertSubview:mapView atIndex:0]; 
[mapView setDelegate:self]; 
mapType.selectedSegmentIndex = [appDelegate.savedMapViewType intValue]; 
[mapView setRegion:region animated:TRUE]; 
+0

您的主要問題的答案是:是的,它可以並且通常是由於優化。至於你的暗示性問題,「爲什麼我在這裏中止?」我不確定。什麼是您的堆棧的回溯,以及正在生成的異常(如果有的話)? – 2009-12-11 19:32:25

回答

1

您從未在上面的代碼中設置region.span.longitudeDelta。我建議使用MKCoordinateRegionMake函數來設置兩個值和兩個增量,所以你不會結束陳舊或隨機的值。

0

Jason的評論是準確和有用的 - 我會「檢查」它,如果可能的話。我的發佈代碼行爲有所不同。一旦我查看堆棧(感謝提示,Jason),我意識到當mapView被設置爲longitudeDelta爲0時,代碼會出錯。這種行爲似乎不僅在調試/發行版和設備/模擬器之間不同,而且顯然是裁剪在最新的iPhone操作系統中。