1

나는 오른쪽 액세서리보기로 단추가있는 주석이있는 mapView가 있습니다. 특수 효과 세부 정보가 나타나 자마자 버튼을 누르면 필요한 정보를 다운로드 할 시간이 없기 때문에 세부 정보가 비어있는 것처럼 보입니다. 내가 찾는 것은 정보가 다운로드되는 한 활동 표시기를 보여주는 것입니다.주석 액세서리로 활동 표시기

-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation{ 

popButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 31, 31)]; 
[popButton addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside]; 
activityI = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 31, 31)]; 
[activityI startAnimating]; 
[popButton addSubview:activityI]; 
[NSThread detachNewThreadSelector:@selector(threadInfo:) toTarget:self withObject:annotation]; 
. 
. 
. 
annView.rightCalloutAccessoryView = popButton; 
} 

-(void) threadInfo: (MKAnnotationView*) info{ 

while ([activityI isAnimating]) { 
    if (ok ==0) { 

    } 
    else{ 

     NSLog(@"ok = %i",ok); 
     popButton = (UIButton*) info.rightCalloutAccessoryView; <--error* 
     popButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; 
     [activityI removeFromSuperview]; 
     [activityI stopAnimating]; 
     ok=0; 
     } 
    } 

} 

는 여기서 "확인"= 정수 1이 과정을 다운로드하여 성공적으로

오류 = 의한 캐치되지 않는 예외 'NSInvalidArgumentException'응용 프로그램 종료, 이유는

완료 = 때 여기서 : 여기에 지금까지 내가 무엇을 가지고 '- [ "주석 클래스 이름은"rightCalloutAccessoryView] : (모든 것을 통신 : 인식 할 수없는 선택기 예를 0x17e7fc60 '나는 activityI 여전히 충돌없이 애니메이션 버튼을 주석도

..

업데이트로 전송 ented out은 테스트를 거쳤으며 동시에 작동하지 않습니다. 주석되지 뭐든지 ...) 내 마지막 시도했다

-(void) threadInfo: (MKAnnotationView*) annView{ 
UIButton* popButtons = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 31, 31)]; 
act = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 31, 31)]; 
[act setColor:[UIColor greenColor]]; 
[act startAnimating]; 
[popButtons addSubview:act]; 
while ([act isAnimating]) { 
      if (ok ==0) { 
     NSLog(@"ok = %i",ok); 

    } 
    else{ 

     NSLog(@"ok = %i",ok); 

     // popButton = (UIButton*) annView.rightCalloutAccessoryView; 
//UIButton* popButtons = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 31, 31)]; 
     popButtons = [UIButton buttonWithType:UIButtonTypeInfoLight]; 
     // UIActivityIndicatorView *currentActivityIndicator = (UIActivityIndicatorView *)[popButton viewWithTag:15]; 
     //currentActivityIndicator.hidden = YES; 
     //[popButtons addSubview:[(UIActivityIndicatorView*) [popButton viewWithTag:15]]]; 
//   [(UIActivityIndicatorView *) [popButton viewWithTag:15] stopAnimating]; 
//   [(UIActivityIndicatorView *) [popButton viewWithTag:15] removeFromSuperview]; 
     annView.rightCalloutAccessoryView = popButtons; 
     //[popButton addSubview:popButtons]; 
     // NSLog(@"view = %@",[popButton viewWithTag:15]); 
     //[act stopAnimating]; 

//   [currentActivityIndicator stopAnimating]; 
//   [currentActivityIndicator removeFromSuperview]; 

     // popButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; 

    //ok=0; 
} 
} 

} 
+0

[NSThread detachNewThreadSelector : @] 메서드에서 annView 대신 annot을 보내고 있다는 것을 알고 있습니다. selector (threadInfo :) toTarget : self withObject : annotation]; – user247

+0

어떻게 해결할 수 있다고 제안하나요? 고맙습니다. – user1780591

+0

이 메소드에서 annotation을 annView로 변경합니다. [NSThread detachNewThreadSelector : @selector (threadInfo :) toTarget : self withObject : annotation]; – user247

답변

0

activityI 당신이 threadInfo에 사용하는 것은 반드시 사용하고있는 annotationView합니다 (info 변수)에 부착 된 아니다. 그것은 어노테이션을 위해 언제든지 호출 될 수있는 viewForAnnotation에 대한 호출에 의해 생성 된 마지막 것입니다. info에 활동 표시기를 가져와야합니다. 당신을 시작시키는 의사 코드가 있습니다. accessoryView를 얻을, 당신은 단지 똑바로 당신은 popButton을 가리키는 된 정보 버튼

info.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeInfoLight]; 

에 accessoryview을 설정

popButton = (UIButton*) info.rightCalloutAccessoryView; 
UIActivityIndicator *currentActivityIndicator = (UIActivityIndicator *)[popButton **Get the right subview here**]; 

또 다른 옵션이 될 것 viewForAnnotation에 추가 작동 표시등이있는 하위 뷰를 얻을 수 rightCalloutAccessoryView로 이동하면 새로운 단추를 가리키고 있지만 rightCalloutAccessoryView는 변경되지 않습니다.

+0

그 중 하나도 작동하지 않았습니다. 활동 표시기가 응답하지 않습니다. – user1780591

+0

은 회전하지 않거나 사라지지 않을 것입니까? – Craig

+0

정확히 ..보기에서 숨기거나 remoe하지 않거나 심지어 버튼을 보여줍니다. – user1780591