2009-06-02 19 views

cevap

41

Oldukça basit. Sadece bir UIActivityIndicatorView oluşturun ve bunu UIAlertView'a bir alt görünüm olarak ekleyin.

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

Teşekkürler, işe yaradı. – ebaccount

+0

Bu harika bir cevabı var, ancak hiç bir düğme yoksa görünümü nasıl reddedebileceğimi merak ediyorum. –

+4

[alert offmissWithClickedButtonIndex: 0 animasyonlu: 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]; 

Bu spinner AlertView ait görevden gizlenmiş olur.

[alert dismissWithClickedButtonIndex:0 animated:YES]; 
2

Durumumda, kodlanmış çerçeve kaynaklarının kullanılmasının kötü olduğunu buldum. Mesajımın bir satırı daha varsa, mesajımın en üstünde gösteriliyor.

Yani ben layouting göstergeli işlevi oluşturursanız boyutu UIAlertView

Bu durumda
+(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; 
} 

, gösterge daima merkez tarafından

Bir satır mesaj:

enter image description here

Daha bir satırlık mesaj:

enter image description here