【问题标题】:UIAlertView not dismissingUIAlertView 不关闭
【发布时间】:2012-07-14 17:49:38
【问题描述】:

我在按钮单击或 (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 消失

提前致谢

【问题讨论】:

    标签: iphone ios alertview


    【解决方案1】:

    您只能在主线程上使用 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];
            });
       });
    }
    

    【讨论】:

      猜你喜欢
      • 2011-10-02
      • 2011-01-04
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      • 1970-01-01
      • 2015-02-21
      • 2014-09-05
      • 2013-09-22
      相关资源
      最近更新 更多