I want to show UIActivityIndicatorView on my iphone when it changing the view. I have written the following code:
- (void)viewDidLoad
{
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[spinner setCenter:CGPointMake(320/2.0, 460/2.0)]; // I do this because I'm in landscape mode
[self.view addSubview:spinner];
}
and on button's click event I want to change the view and in between that time I want to show that indicatorView So, I write
-(IBAction)buttonClick:(id)sender
{
[spinner startAnimating];
ViewController *lController = [[ViewController alloc] initWithNibName: @"View" bundle:nil];
self.viewController = lController;
[lController release];
//
[[self mainController] dismissModalViewControllerAnimated:YES];
[lViewController.view removeFromSuperview];
[self.view addSubview: lController.view];
[spinner stopAnimating];
}
It is not displaying the Indicator, So plz tell me where I am wrong?