2009-06-02 4 views

Antwort

41

Es ist ziemlich einfach. Erstellen Sie einfach eine UIActivityIndicatorView und fügen Sie sie als Unteransicht der UIAlertView hinzu.

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

    [alert show]; 
+0

Danke, es hat funktioniert. – ebaccount

+0

Es ist eine gute Antwort, aber ich frage mich, wie kann ich es aus der Sicht ablehnen, wenn es keine Taste gibt? –

+4

[Warnung kündigenWithClickedButtonIndex: 0 animiert: YES]; –

0
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; 
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; 
spinner.center = CGRectMake(xcords, ycords, width, height); 
[alert addSubview:spinner]; 
[spinner startanimating]; 
[alert show]; 

wird auf abtun von Alertview Dieser Spinner versteckt.

2

In meinem Fall fand ich, was mit hartcodierten Frame-Ursprungs ist es schlecht. Und wenn meine Nachricht mehr als eine Zeile enthält, zeigt die Anzeige den Anfang meiner Nachricht an.

So erstellen i-Funktion mit Layouten Kennzeichen, wenn Größe UIAlertView

+(UIAlertView*) progressAlertWithTitle:(NSString*) title andMessage:(NSString*) message andDelegate:(id)delegate{ 
    UIAlertView *progressAlert = [[UIAlertView alloc] init]; 
    [progressAlert setTitle:title]; 
    [progressAlert setMessage:message]; 
    [progressAlert setDelegate:delegate]; 
    UIActivityIndicatorView *progress=nil; 
    progress= [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 

    [progressAlert addSubview:progress]; 
    [progress startAnimating]; 

    [progressAlert show]; 

    progress.frame=CGRectMake(progressAlert.frame.size.width/2-progress.frame.size.width, progressAlert.frame.size.height-progress.frame.size.height*2, progress.frame.size.width, progress.frame.size.height); 


    return progressAlert; 
} 

In diesem Fall Indikator immer von Mitte

Eine Zeile Nachricht:

enter image description here

Mehr eine Zeilennachricht:

enter image description here

Verwandte Themen