【问题标题】:Activity Indicator is not showing on images活动指示器未显示在图像上
【发布时间】:2014-02-26 12:13:16
【问题描述】:

您好,我正在尝试将图像从 iphone 上传到服务器,因为我为用户提供了活动指示符,以便在单击上传时知道图像正在上传,它将显示活动指示符几分钟。

但我的问题是活动指示器只显示在几张图片中它没有显示在所有图片上请告诉我如何解决这个问题。

我的活动编码。

-(void)temp{
    spinner = [[UIActivityIndicatorView alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    //spinner = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:]
     spinner.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
    [spinner setCenter:CGPointMake(160, 240)]; // (mid of screen) I do this because I'm in landscape mode
    [self.view addSubview:spinner];
    spinner.color = [UIColor blackColor];
    spinner.backgroundColor = [UIColor colorWithWhite:0.2 alpha:0.4];
    [spinner startAnimating];
    [spinner release];
}

-(void) myMethod{
    [spinner stopAnimating];
    spinner.hidden = YES;
    spinner.color = [UIColor yellowColor];
}

- (IBAction)pushUpload:(id)sender {

    [self temp];
    [self performSelector:@selector(myMethod) withObject:nil afterDelay:5.0f];

}

【问题讨论】:

  • 你是否在imageview上或imageview下面添加了指示器????
  • 通过提供的有限信息,有一点很清楚。您正在尝试为多个图像重用单个活动指示器。
  • @NiravPatel 上面的图像查看它只显示在少数图像中,但它没有显示所有图像请告诉如何解决它..
  • @Desdenova 每次按下活动指示器时应显示请告诉我如何解决此问题
  • 尝试替换这一行“spinner.backgroundColor = [UIColor colorWithWhite:0.2 alpha:0.4];”带有 spinner.backgroundColor = [UIColor bluecolor]; .请检查背景颜色是否变为蓝色...

标签: ios iphone activity-indicator


【解决方案1】:

使用 AsynchronousImageView 代替 ActivityIndi​​cator 会在加载图像时自动添加 ActivityIndi​​cator。
[AsynObj loadImageFromURL:[NSURL URLWithString:ImageUrl]];

您可以从以下链接https://github.com/nicklockwood/AsyncImageView获取 AsyncImageView 类


希望对你有帮助!

【讨论】:

    猜你喜欢
    • 2016-12-12
    • 2016-06-25
    • 2012-01-25
    • 2023-04-07
    • 1970-01-01
    • 2019-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多