我怎样才能在我的应用中使用进度视图

时间:2015-02-23 13:14:44

标签: ios objective-c uiprogressview

我正在尝试使用以下代码将图片保存到我的应用中的相册:

 -(void)download:(UIButton *)downloadbtn{

    j=320*downloadbtn.tag;

    selectedIndex=downloadbtn.tag;

    NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:[live_god_img objectAtIndex:selectedIndex]]];

    UIImage*img=[UIImage imageWithData:data];

    UIImageWriteToSavedPhotosAlbum(img, self, nil, nil);

    UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@"Success..!" message:@"Image Saved to the Photos" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

    [alert show];

}

当图像保存到相册时,将显示警报视图,但我想在将图像保存到相册时显示进度视图。我不知道如何使用UIProgressView。我该怎么做?

2 个答案:

答案 0 :(得分:0)

完成本教程first

您可以在方法中尝试这样做。

- (IBAction)startProgress:(id)sender
    {
     progressValue = 0.0f;
     [self increaseProgressValue];
   }

-(void)increaseProgressValue
   {
   if(progressView.progress<1)
      {
    progressValue = progressValue+0.1;
    progressView.progress = progressValue;

   [self performSelector:@selector(increaseProgressValue) withObject:self afterDelay:0.2];
     }
  }

答案 1 :(得分:0)

查看此问题的答案: want to display UIProgressView on UIAlertView

UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"" message:@"" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
UIProgressView *pv = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
pv.frame = CGRectMake(20, 20, 200, 15);
pv.progress = 0.5;
[av addSubview:pv];
[av show];

下次我建议您使用谷歌或搜索功能......我的意思是,认真......

(这个问题在这里也可能是重复的......)