在子线程中显示提示信息框的公共方法

#pragma mark - 在子线程中显示提示信息框

//在子线程中显示提示信息框
-(void)showAlertwithTitle:(NSString *)title message:(NSString *)msg cancleButtonTitle:(NSString *) cancleTitle otherButtonTitle:(NSString *)otherButtonTitle tag:(NSString *)tag
{
    NSArray *array = [NSArray arrayWithObjects:title,msg,cancleTitle,otherButtonTitle,tag, nil];
    [self performSelectorOnMainThread:@selector(doAlert:) withObject:array waitUntilDone:NO];   //回归主线程
}

//弹出信息显示框
-(void)doAlert:(NSArray *)array
{
    NSString *title = nil;
    if (![[array objectAtIndex:0] length]==0) title = [array objectAtIndex:0];

    NSString *msg = nil;
    if (![[array objectAtIndex:1] length]==0) msg = [array objectAtIndex:1];

    
    NSString *cancleTitle = nil;
    if (![[array objectAtIndex:2] length]==0) cancleTitle = [array objectAtIndex:2];
    
    NSString *otherButtonTitle = nil;
    if (![[array objectAtIndex:3] length]==0) otherButtonTitle = [array objectAtIndex:3];

    
    NSString *tag = @"0";
    if (![[array objectAtIndex:4] length]==0) tag = [array objectAtIndex:4];

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:cancleTitle otherButtonTitles:otherButtonTitle,nil];
    alert.tag = [tag integerValue];
    [alert show];
    [alert release];
}
原文地址:https://www.cnblogs.com/ygm900/p/3491367.html