I have a refresh button on my navigationbar
buttonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(buttonItemClicked)];
self.navigationItem.rightBarButtonItem = buttonItem;
-(void)buttonItemClicked{
NSLog(@"buttonItemclicked");
myView.labelName.text = nil;
myView.otherLabelName.text = nil;
[spinner startAnimating]
[spinnerView setHidden:NO];
[self requestAPI];
[spinner stopAnimating];
[spinnerView setHidden:YES];
}
If I go in and out of the view, it works fine. But when I call the same methods in buttonItemClicked, it doesn´t work. I also tried calling the view methods inside my action method, but that doesn´t work either.
What I´m trying to do is set my labels to nil, add my UIActivityIndicatorView
and remove it after the labels are set again.
I have already tried [self.view setNeedsDisplay];
The refresh it self works, but the animations doesn´t work.
Any suggestions?
Try
[myView setsNeedToDisplay];
.The animation is not working because you call startAnimating and stopAnimating (and setHidden) in the same method. The render start at the end of the method call. You need to set
in
requestAPI
.Edit:
Using Grand Central Dispatch. Like: