2011-10-08 3 views
0

저는 MKMapView를 사용하여지도에 주석 핀을 배치했습니다. 나는 30 개의 서로 다른 위치에 대해지도에 30 개의 핀을 배치하고 각각의 추가 위치를 추가 한 후 iPhone SDK를 실행하도록 노력하고 있습니다. 그런 다음, 아무 데서나, 그것은 부서지기 시작하고 저에게 두려운 'SIGABRT'를주었습니다. AG !!MKMapView에서 여러 주석을 시도 할 때 SIGABRT 오류가 발생했습니다.

필자는 구문에 약간의 오류가있을 수 있음을 알고 있지만 이전에 작동했던 코드를 복사하여 붙여 넣기 때문에 손실이 발생합니다. 나는 MKCoordinateRegionMake를 사용하여 모든 것을 더 간결하게 만들 것을 고려하고있다. (나는 이것이 옵션 일 수 있음을 읽었다.)하지만 이미 10 점포에 들어갔다. 그래서 나는 그것을 바꾸기 위해 많은 시간을 필요로 할 것이다. 이것이 빠른 해결책이라면해야 할 일.

나는 하나의 좌표를 제외한 모든 것을 꺼내 진행했다. 그런 다음 다시 한 번 더 추가했고 작동했습니다. 몇 가지 이유 때문에 시간이 많이 걸렸지 만 때로는 잠겨서 충돌 할 수도있었습니다. 나는 그것이 문제였던 특정 위치 일 뿐이라고 생각했지만, 특히 어떤 위치의 구문에도 문제가없는 것처럼 보였다. 그래서 지금 나는 그것을 일으키는 것에 대한 손실이 있습니다.

내가 옳지 않다는 것을 할당하고 해제하는 문제가 될 수 있다고 생각합니다. 코드에서 할당 된 공간을 "해제"하려고 시도했지만 문제가 지속됩니다. 나 또한 같은 문제가 코드 중에 할당 된 공간을 공개하지 않고 그것을 시도했다. 여기

내가 함께 일하고 있어요 코드입니다 (모든 코드가 시간에 일을, 그래서 제목, 자막을 설정하고 MillersLocations 좌표했습니다 올바르게 파일) :

MapViewController.m

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    //Miller's Neighborhood Market #56 
    MKCoordinateRegion store56; 
    store56.center.latitude = 36.8605679; 
    store56.center.longitude = -76.2866713; 
    store56.span.latitudeDelta = 0.1; 
    store56.span.longitudeDelta = 0.1; 
    [mapView setRegion:store56 animated:YES]; 

    MillersLocations *ann56 = [[MillersLocations alloc]init]; 
    ann56.title = @"Store #56"; 
    ann56.subtitle = @"Come check us out!"; 
    ann56.coordinate = store56.center; 
    [mapView addAnnotation:ann56]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 


    //Miller's Neighborhood Market #66 
    MKCoordinateRegion store66; 
    store66.center.latitude = 37.0942970; 
    store66.center.longitude = -76.4584890; 
    store66.span.latitudeDelta = 0.1; 
    store66.span.longitudeDelta = 0.1; 
    [mapView setRegion:store66 animated:YES]; 

    MillersLocations *ann66 = [[MillersLocations alloc]init]; 
    ann66.title = @"Store #66"; 
    ann66.subtitle = @"Come check us out!"; 
    ann66.coordinate = store66.center; 
    [mapView addAnnotation:ann66]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 

    //Miller's Neighborhood Market #21 
    MKCoordinateRegion store21; 
    store21.center.latitude = 37.0385289; 
    store21.center.longitude = -76.4004810; 
    store21.span.latitudeDelta = 0.1; 
    store21.span.longitudeDelta = 0.1; 
    [mapView setRegion:store21 animated:YES];  

    MillersLocations *ann21 = [[MillersLocations alloc]init]; 
    ann21.title = @"Store #21"; 
    ann21.subtitle = @"Come check us out!"; 
    ann21.coordinate = store21.center; 
    [mapView addAnnotation:ann21]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 


    //Miller's Neighborhood Market #67 
    MKCoordinateRegion store67; 
    store67.center.latitude = 37.6823690; 
    store67.center.longitude = -77.5898330; 
    store67.span.latitudeDelta = 0.1; 
    store67.span.longitudeDelta = 0.1; 
    [mapView setRegion:store67 animated:YES]; 

    MillersLocations *ann67 = [[MillersLocations alloc]init]; 
    ann67.title = @"Store 67"; 
    ann67.subtitle = @"Come check us out"; 
    ann67.coordinate = store67.center; 
    [mapView addAnnotation:ann67]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 

    //Miller's Neighborhood Market #49 
    MKCoordinateRegion store49; 
    store49.center.latitude = 36.8550990; 
    store49.center.longitude = -76.1355950; 
    store49.span.latitudeDelta = 0.1; 
    store49.span.latitudeDelta = 0.1; 
    [mapView setRegion:store49 animated:YES]; 

    MillersLocations *ann49 = [[MillersLocations alloc]init]; 
    ann49.title = @"Store 49"; 
    ann49.subtitle = @"Come check us out"; 
    ann49.coordinate = store49.center; 
    [mapView addAnnotation:ann49]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 

    //Miller's Neighborhood Market #82 
    MKCoordinateRegion store82; 
    store82.center.latitude = 36.7848840; 
    store82.center.longitude = -76.1587459; 
    store82.span.latitudeDelta = 0.1; 
    store82.span.latitudeDelta = 0.1; 
    [mapView setRegion:store82 animated:YES]; 

    MillersLocations *ann82 = [[MillersLocations alloc]init]; 
    ann82.title = @"Store 82"; 
    ann82.subtitle = @"Come check us out"; 
    ann82.coordinate = store82.center; 
    [mapView addAnnotation:ann82]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 

    //Miller's Neighborhood Market #40 
    MKCoordinateRegion store40; 
    store40.center.latitude = 37.1236680; 
    store40.center.longitude = -76.5093960; 
    store40.span.latitudeDelta = 0.1; 
    store40.span.latitudeDelta = 0.1; 
    [mapView setRegion:store40 animated:YES]; 

    MillersLocations *ann40 = [[MillersLocations alloc]init]; 
    ann40.title = @"Store 40"; 
    ann40.subtitle = @"Come check us out"; 
    ann40.coordinate = store40.center; 
    [mapView addAnnotation:ann40]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 

    //Miller's Neighborhood Market #55 
    MKCoordinateRegion store55; 
    store55.center.latitude = 36.7704630; 
    store55.center.longitude = -76.6058140; 
    store55.span.latitudeDelta = 0.1; 
    store55.span.latitudeDelta = 0.1; 
    [mapView setRegion:store55 animated:YES]; 

    MillersLocations *ann55 = [[MillersLocations alloc]init]; 
    ann55.title = @"Store 55"; 
    ann55.subtitle = @"Come check us out"; 
    ann55.coordinate = store55.center; 
    [mapView addAnnotation:ann55]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 

    //Miller's Neighborhood Market #58 
    MKCoordinateRegion store58; 
    store58.center.latitude = 36.7818390; 
    store58.center.longitude = -76.0479090; 
    store58.span.latitudeDelta = 0.1; 
    store58.span.latitudeDelta = 0.1; 
    [mapView setRegion:store58 animated:YES]; 

    MillersLocations *ann58 = [[MillersLocations alloc]init]; 
    ann58.title = @"Store 58"; 
    ann58.subtitle = @"Come check us out"; 
    ann58.coordinate = store58.center; 
    [mapView addAnnotation:ann58]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 

    //Miller's Neighborhood Market #57 
    MKCoordinateRegion store57; 
    store57.center.latitude = 36.8216160; 
    store57.center.longitude = -76.4246680; 
    store57.span.latitudeDelta = 0.1; 
    store57.span.latitudeDelta = 0.1; 
    [mapView setRegion:store57 animated:YES]; 

    MillersLocations *ann57 = [[MillersLocations alloc]init]; 
    ann57.title = @"Store 57"; 
    ann57.subtitle = @"Come check us out"; 
    ann57.coordinate = store57.center; 
    [mapView addAnnotation:ann57]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 

    //Miller's Neighborhood Market #90 
    MKCoordinateRegion store90; 
    store90.center.latitude = 38.1330690; 
    store90.center.longitude = -77.5124230; 
    store90.span.latitudeDelta = 0.1; 
    store90.span.latitudeDelta = 0.1; 
    [mapView setRegion:store90 animated:YES]; 

    MillersLocations *ann90 = [[MillersLocations alloc]init]; 
    ann90.title = @"Store 90"; 
    ann90.subtitle = @"Come check us out"; 
    ann90.coordinate = store90.center; 
    [mapView addAnnotation:ann90]; 
    [MillersLocations release]; 
    //Not sure if release should be on this syntax 

    //56,66,21,67,49,90,82,40,55,58,57 

} 

오류 (스레드 1 : 프로그램 수신 신호 "SIGABRT")는 항상 다음 줄에서 발생합니다.

[mapView setRegion : store57 animated : YES];

또는 상점 90에서도 마찬가지입니다. 거기에 일어난 다른 상점들도 있지만 항상 그 라인에 있습니다. 나는 운율이나 이유를 찾지 않았습니다.

도움을받을 수있는 사람 덕분에! 조금 오래 오래 있으면 사과드립니다. 도움이 필요한 정보가 있는지 확인하고 싶었습니다. ("[지도보기 릴리스];") 그것은 일

편집은 한 번 내가 제대로 내가 만든 다음이를 해제 코드의 가지고있는 MKMapView 아울렛을 합성. 나는 MapViews가 오류의 원인이었을 자신을 릴리스한다고 가정하고 있습니다.

괜찮 았는데 다른 주석을 추가하려고했고 다시 충돌했습니다. 새 주석을 삭제하면 작동하므로 더 추가 할 때 문제가 발생합니다. AG. 어떤 도움을 주셔서 감사합니다. 감사.

답변

1

SIGABRT의 가장 큰 이유는 store49의 영역이 유효하지 않기 때문에 NSInvalidArgumentException과 SIGABRT가되는 것입니다.

store49 (및 그 이후의 모든 상점)의 경우 longitudeDelta이 설정되지 않습니다.
latitudeDelta 만 설정 중입니다 (두 번).

latitudeDelta 복제본을 longitudeDelta으로 고정하십시오.- 생성되는 클래스의 인스턴스가 아니라

[MillersLocations release]; 

이것은 MillersLocation 클래스에 release 전화를 시도합니다


또 다른 문제

이입니다. 모든 행은 다음과 같이 변경해야합니다.

[ann56 release]; 

또한 주석을 설정할 때마다 영역을 만들 필요가 없습니다. 예를 들어, 당신은이 작업을 수행 할 수 있습니다

MillersLocations *ann56 = [[MillersLocations alloc]init]; 
ann56.title = @"Store #56"; 
ann56.subtitle = @"Come check us out!"; 
ann56.coordinate = CLLocationCoordinate2DMake(36.8605679, -76.2866713); 
[mapView addAnnotation:ann56]; 
[ann56 release]; 

모든 주석을 추가 한 후, 당신은 (만약 당신이 원하는 경우)하거나 마지막 주석을 표시하고 setRegion를 호출하는 모든 주석을 둘러싸는 영역을 만들 수 있습니다 끝에 한 번.

또한 plist에 상점을 저장하고 코드에서 개별적으로 작성하는 대신 주석을 작성하기 위해 plist를 반복 할 수 있습니다.

마지막으로, IBOutlet 인 경우에도 [mapView release]; (dealloc)을 제거하지 않아야합니다.

+0

와우, 정말 고마워요. 난 latitudeDelta 문제로 문법 오류를 간과했다고 믿을 수 없어. 그러한 큰 도움은 정말 감사합니다. – MillerMedia

+1

(이 게시물을 읽는 사람은 누구나 도움이됩니다.) CLLocationCoordinate2DMake를 사용하려면 CoreLocations Framework를 추가하고 가져와야합니다. – MillerMedia

관련 문제