+(DisplayErrorMsg *)sharedDisplayErrorMsg
{
    static DisplayErrorMsg *instance = nil;
    @synchronized(instance)
    {
        if (instance == nil) {
            instance = [[DisplayErrorMsg alloc] init];
        }
    }
    return instance;
}

-(void)showAlertView:(NSString *)title Message:(NSString *)msg
{
    NSArray *array = [NSArray arrayWithObjects:title,msg, nil];
    [self performSelectorOnMainThread:@selector(doAlert:) withObject:array waitUntilDone:NO];
}

//在没有界面的类中,实现弹出UIAlertView
-(void)doAlert:(NSArray *)array
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[array objectAtIndex:0] message:[array objectAtIndex:1] delegate:nil cancelButtonTitle:@"关闭" otherButtonTitles:nil];

    AppDelegate *delegate = [[UIApplication sharedApplication] delegate];   //获取界面的思路

    [delegate.window addSubview:alert];

    [alert show];
    [alert release];
 
}

 

相关文章:

  • 2022-02-07
  • 2021-06-19
  • 2021-09-01
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
猜你喜欢
  • 2022-02-10
  • 2021-08-05
  • 2022-12-23
  • 2022-02-10
  • 2021-12-06
  • 2022-02-05
  • 2021-10-16
相关资源
相似解决方案