2012-07-14 1 views
2

을 기각하지UIAlertView a 버튼을 클릭하거나 (IBAction를) 내에서 다음 내가 사용

- (IBAction)HistoryBtn:(id)sender { 
    self startReport]; 
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 
     //============================ 
      so some long processing code   
     //============================    
     [self stopReport]; 
    }); 
} 

경우

-(void) startReport 
{ 
    alert = [[UIAlertView alloc] initWithTitle:@"Generating PDF" message:@" " delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; 
    UIActivityIndicatorView *progress= [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)]; 
    progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; 
    [alert addSubview:progress]; 
    [alert setDelegate:self]; 
    [progress startAnimating]; 

    [alert show]; 
} 

-(void) stopReport 
{ 
    NSLog(@" Stop Called "); 
    [self.alert dismissWithClickedButtonIndex:0 animated:NO]; 
    self.alert = nil; 

    NSLog(@" Stop Called "); 
} 

문제는 최대 AlertView 팝업 내가 버튼의 작품을 볼 수있다, 다음 StopReport 호출하지만 AlertView가 유지하는 방법은 AlertView 미리 멀리

감사 가고 얻을 수

답변

3

기본 스레드에서만 UI로 작업해야합니다.

- (IBAction)HistoryBtn:(id)sender { 
    self startReport]; 
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 
     //============================ 
      so some long processing code   
     //============================  
     dispatch_async(dispatch_get_main_queue(), ^{ 
      [self stopReport]; 
     }); 
    }); 
} 
+0

그레이트 고맙습니다. – BarryF

관련 문제