I’m building an article reading app. I’m using AMSliderMenu(https://github.com/SocialObjects-Software/AMSlideMenu) library for menu list.
I am unable to implement UIActivityIndicator
, when i click on table cell in AMSlideMenu it takes time to load another view because data is load into anther view.
I want to give UIActivityIndicator
when user click on cell UIActivityIndicator
perform till the time it opens another view.
Here is my code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.center = CGPointMake(160, 240);
spinner.hidesWhenStopped = YES;
[self.view addSubview:spinner];
[spinner startAnimating];
dispatch_queue_t downloadQueue = dispatch_queue_create("downloader", NULL);
dispatch_async(downloadQueue, ^{
[NSThread sleepForTimeInterval:10];
dispatch_async(dispatch_get_main_queue(), ^{
[spinner stopAnimating];
});
});
NSString *segueIdentifier = [self.mainVC segueIdentifierForIndexPathInLeftMenu:indexPath];
if (segueIdentifier && segueIdentifier.length > 0)
{
[self performSegueWithIdentifier:segueIdentifier sender:self];
}
}
Declare the
UIActivityIndicatorView
in the class level scope.Perform the segue in the main queue:
Stop the spinner when doing the segue: