我不知道如何解释,但是...如果你理解我说的“加载圈”完美,我只想这样做
// Start loading in the middle of the screen frozing all interaction
for (int c = 0; c < ([barcos count] - 1); c++)
{
NSArray *datos = [[barcos objectAtIndex:c] componentsSeparatedByString:@";"];
NSString *nombreImagen = [datos objectAtIndex:2];
NSURL *accesoFtp = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",urlFtp,nombreImagen]];
NSData *imagen = [NSData dataWithContentsOfURL:accesoFtp];
[imagen writeToFile:[[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"Barcos/%@",nombreImagen]]] atomically:NO];
}
// Stop frozing all interaction and remove the loading circle
可能我必须添加一个线程或其他东西,但我不知道如何做我想要的,我希望你能再次帮助我。谢谢。
编辑:
UIActivityIndicatorView *activityIndicator;
activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
activityIndicator.center = self.view.center;
[self.view addSubview: activityIndicator];
activityIndicator.startAnimating;
dispatch_queue_t queue = dispatch_get_global_queue(0,0);
dispatch_async(queue, ^{
for (int c = 0; c < ([barcos count] - 1); c++)
{
NSArray *datos = [[barcos objectAtIndex:c] componentsSeparatedByString:@";"];
NSString *nombreImagen = [datos objectAtIndex:2];
NSURL *accesoFtp = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",urlFtp,nombreImagen]];
NSData *imagen = [NSData dataWithContentsOfURL:accesoFtp];
[imagen writeToFile:[[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"Barcos/%@",nombreImagen]]] atomically:NO];
}
dispatch_sync(dispatch_get_main_queue(), ^{
activityIndicator.stopAnimating;
});
});
两件事情
1.- The activity indicator is too small but works, if I can to it bigger or same size but make darker the background would be better (Thanks!)
2.- I have a warning with startAnimating and stopAnimating "Property access result unused - getters should not be used for side effects"
谢谢 =)