How can I show alertview with activity indicator?

后端 未结 7 2269
青春惊慌失措
青春惊慌失措 2020-11-30 09:52

I want to show alertview with message: \"Loading data\" and spinning activity indicator. How can I do this?

7条回答
  •  没有蜡笔的小新
    2020-11-30 10:34

    you can add a label and activityindicator as subviews of your alert view. you have to do some thing like this...

    - (IBAction)showAlertWithActivity:(id)sender{
    
    alerta = [[UIAlertView alloc] initWithTitle:@"Guardando datos..."
                                                message:@"\n"
                                               delegate:self
                                      cancelButtonTitle:nil
                                      otherButtonTitles:nil];
    
            UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
            spinner.center = CGPointMake(139.5, 75.5); // .5 so it doesn't blur
            [alerta addSubview:spinner];
            [spinner startAnimating];
            [alerta show];
    
    
            [self performSelector:@selector(close) withObject:self afterDelay:1];
    
    
        }
        -(void)close{
    
            [alerta dismissWithClickedButtonIndex:0 animated:YES];
    
        }
    

提交回复
热议问题