views:

76

answers:

1

Hi

I have defined a class that does a lengthy task and I call it from several other classes. Now I want to show an Activity Indicator while this task is doing it's thing, and then remove it once it's done. Since this is just a boring background task, this class doesn't have a view, and I guess that is where I run into my problem. I can't get this thing to show.

This is what I have done in my class:

    UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];

[activityIndicator setCenter:CGPointMake(160.0f, 208.0f)];
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;

UIView *contentView = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] applicationFrame]];

[contentView addSubview:activityIndicator];
[activityIndicator startAnimating];

// Do the class lengthy task that takes several seconds.....


[contentView release];
[activityIndicator release];

I guess I do something wrong when I get the contentView, but how should I get it properly?

Thanks for any advices...

A: 

You aren't 'getting' the contentView, you're creating a new view that isn't being displayed anywhere. This class will need to be a view controller, or you'll need to have a view controller somewhere display this view.

Rob Lourens
ThanksI was hoping that it would be as simple as displaying an alert view, which I do from the class when something goes wrong.Will do some re-thinking and see what I will come up with...
Structurer