2015-02-23 21 views
1

我嘗試使用下面的代碼保存圖像從我的應用程序的照片相冊:我怎麼可以簡單地使用發展觀在我的應用程序

-(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。我該怎麼做?

+1

你不能,除非你的下載操作是異步的。由於您的代碼目前正在寫入(同步),因此無法執行此操作。 – Cyrille 2015-02-23 14:14:03

回答

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]; 
    } 
    } 
+0

我同意你@LittleBobbyTables。我正在考慮問問題的人的方面,而不是其他堆棧流量用戶。我將提供必要的信息並更新答案。 :) – 2015-02-23 14:06:31

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]; 

下一次我建議你使用谷歌或搜索功能......我的意思是,認真...

(這裏的問題也可能是一個重複的btw ...)

相關問題