views:

57

answers:

2

Hi all,

I'm trying to add an activityIndicator on a modalViewController.

Basically I want to start animating this activityIndicator after user presses a button on this modalViewController. But what's happening is whatever I'm doing before firing presentModalViewController on this modalViewController is staying constant i.e. If I simply add activityIndicator and after presenting modalView, then even if I start it it doesn't show up. But if Before preseting this modalViewController if I fire [activity startAnimating]; then after presenting the modalView activity shows up animating.

So basically, I want to simply add the activityIndicator on modalViewController and start animating it after I press a button.

I'm using the following code:

  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];

Can anybody please help?

Thanx in advance.

A: 

Add it as a subview.

jrtc27
Can you please be specific? I'm a bit confused..
neha
Just take your view, and call `[whatevertheviewis addSubview:anactivityindicatorview];`
jrtc27
A: 

Inside your ViewController, in viewDidLoad or in ViewWillAppear try this:

  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
Manjunath