I want to show alertview with message: \"Loading data\" and spinning activity indicator. How can I do this?
Add This in your .h file
UIAlertView *connectingAlert;
And Add these two functions in your .m files
//show loading activity.
- (void)startSpinner:(NSString *)message {
// Purchasing Spinner.
if (!connectingAlert) {
connectingAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(message,@"")
message:nil
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
connectingAlert.tag = (NSUInteger)300;
[connectingAlert show];
UIActivityIndicatorView *connectingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
connectingIndicator.frame = CGRectMake(139.0f-18.0f,50.0f,37.0f,37.0f);
[connectingAlert addSubview:connectingIndicator];
[connectingIndicator startAnimating];
}
}
//hide loading activity.
- (void)stopSpinner {
if (connectingAlert) {
[connectingAlert dismissWithClickedButtonIndex:0 animated:YES];
connectingAlert = nil;
}
// [self performSelector:@selector(showBadNews:) withObject:error afterDelay:0.1];
}
then call
[self startSpinner:@"Your message........"];
[self stopSpinner];