2010-07-15 5 views
0

J'essaye d'ajouter un activityIndicator sur un modalViewController.Ajout d'un indicateur d'activité sur modalViewController iphone

Fondamentalement, je veux commencer à animer ce activityIndicator après que l'utilisateur appuie sur un bouton sur ce modalViewController. Mais ce qui se passe est ce que je fais avant de déclencher presentModalViewController sur ce modalViewController reste constant c'est-à-dire Si j'ajoute simplement activityIndicator et après avoir présenté modalView, alors même si je le lance il n'apparaît pas. Mais si Avant de prescrire ce modalViewController si je tire [activité startAnimating]; puis après avoir présenté l'activité modalView apparaît animant.

Donc, fondamentalement, je veux simplement ajouter le activityIndicator sur modalViewController et commencer à l'animer après avoir appuyé sur un bouton.

J'utilise le code suivant:

imageUploadView = [[UIViewController alloc]initWithNibName:nil bundle:nil]; 
    CGRect frame = CGRectMake(140.0, 410.0, 25.0, 25.0); 
    loading = [[UIActivityIndicatorView alloc] initWithFrame:frame]; 
    [loading sizeToFit]; 
    loading.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | 
    UIViewAutoresizingFlexibleRightMargin | 
    UIViewAutoresizingFlexibleTopMargin | 
    UIViewAutoresizingFlexibleBottomMargin); 

    [imageUploadView.view addSubview:loading]; 
    [_picker_ presentModalViewController:imageUploadView animated:YES]; 

Quelqu'un peut-il s'il vous plaît aider?

Merci d'avance.

Répondre

0

Ajoutez-le en tant que sous-vue.

+0

Pouvez-vous s'il vous plaît être plus précis? Je suis un peu confus .. – neha

+0

Il suffit de prendre votre point de vue, et appelez '[whatevertheviewis addSubview: anactivityindicatorview];' – jrtc27

1

l'intérieur de votre ViewController, en viewDidLoad ou viewWillAppear essayez ceci:

CGRect frame = CGRectMake(140.0, 410.0, 25.0, 25.0); 
    loading = [[[UIActivityIndicatorView alloc] initWithFrame:frame] autoRelease]; 
    [loading sizeToFit]; 
    loading.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | 
    UIViewAutoresizingFlexibleRightMargin | 
    UIViewAutoresizingFlexibleTopMargin | 
    UIViewAutoresizingFlexibleBottomMargin); 
    [self.view addSubView:loading]; 
    loading.startAnimateing 
+0

L'avant-dernière ligne doit être "addSubview", pas de majuscule "v". – DenVog

0

Je l'ai résolu en utilisant le code ci-dessous

activityIndicatorObject = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 

// Set Center Position for ActivityIndicator 

activityIndicatorObject.center = CGPointMake(150, 250); 
activityIndicatorObject.backgroundColor=[UIColor grayColor]; 

// Add ActivityIndicator to your view 
[self.view addSubview:activityIndicatorObject]; 

activityIndicatorObject.hidesWhenStopped=NO; 

[activityIndicatorObject startAnimating]; 
Questions connexes