lundi 30 décembre 2013

addSubview in UIAlertView deprecated in iOS7


There is a solution....

UIAlertView *alertView;

//a simple alert view with a simple message:
alertView = [[UIAlertView alloc]initWithTitle:nil message:@"My message here..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
    

//a simple activity indicator:
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.frame= CGRectMake(50, 10, 37, 37);
activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;    
[activityIndicator startAnimating];

//the magic line below,   
//we associate the activity indicator to the alert view: (addSubview is not used)
[alertView setValue:activityIndicator forKey:@"accessoryView"];
    
[alertView show];

Aucun commentaire:

Categories