Reputation: 10245
A fairly short question, How can I load a UIActivityIndicatorView for say 0.5 seconds from when the view loads?
I have had a look around but most tutorials are using the webview where an if statment is created where (webview.loading) is used to define the length of the animation etc.. so i am just woundering how to do this when ever the view loads for .5 second.
Currently I have a method that centers the previously selected cell which I would like the indicator to last untill this is done.
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self performSelector:@selector(scrollToRowAtIndexPath) withObject:nil afterDelay:1.0];
}
- (void)scrollToRowAtIndexPath
{
[self.tableView reloadData];
[self.tableView scrollToRowAtIndexPath:oldCheckedIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
}
Upvotes: 1
Views: 4058
Reputation: 2030
Maybe some like that helps:
-(void)viewDidLoad
{
[super viewDidLoad];
//... all your previous charge.
UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activity.hidesWhenStopped = YES;
activity.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleWidth;
[yourTable addSubview:activity];
[activity startAnimating];
[activity performSelector:@selector(stopAnimating) withObject:nil afterDelay:0.5];
[activity release];
}
Upvotes: 2