作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不知道该怎么解释,但是...如果当我说“加载圆”完美时您理解我,我只想这样做
// 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"
最佳答案
可以使用MBProgressHUD完成
还要检查以下代码:
//Show your activity indicator here
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(), ^{
//hide that activity indicator here
});
});
activityIndicator.startAnimating;
activityIndicator.stopAnimating;
[activityIndicator startAnimating];
[activityIndicator stopAnimating];
关于ios - 如何在我的iOS应用程序中添加UIActivityIndicator View?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14477253/
我是一名优秀的程序员,十分优秀!