0

I added a UIProgressView to my UIActionSheet to indicate the download progress. So I do not want my UIActionSheet to be dismissed when user click the download button in it.

But is there a way to do that ?

Right now I implement didDismissWithButtonIndex delegate method to show UIActionSheet again after it was dismissed. But I was hoping there is a better way.

DShah
  • 9,768
  • 11
  • 71
  • 127
Qiulang
  • 10,295
  • 11
  • 80
  • 129

2 Answers2

2

UIActionSheet is a modal view, which means that it blocks UI completely. Since blocking UI is considered a bad practice, preventing an action sheet from dismissing is not supported. Instead, you should make a completely separate progress indicator outside the action sheet.

Costique
  • 23,712
  • 4
  • 76
  • 79
  • No I did not block it completely. It still has the cancel button as UIActionSheet should. And user can dismiss UIActionSheet by clicking cancel button. I just did not want it to be dismissed when user clicks the download button. – Qiulang Dec 26 '11 at 07:31
  • iOS 8 won't let you do that anymore. And your word " you should make a completely separate progress indicator outside the action sheet." was right from the beginning. Thanks! – Qiulang Sep 30 '14 at 08:34
0

@Yar, thanks for the answer, I will try your solution some other time.

But I am also satisfied with my current solution. UIActionSheet.h said

// Called when a button is clicked. **The view will be automatically dismissed after this call returns**
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;

So I guess hit any buttons will always dismiss action sheet. Then my solution is first hide progress bar; when user hits download button, show action sheet again but hide the download button and show progress bar.

The cancel button is always there in case user wants to cancel download even after download is started.

Hiren
  • 12,720
  • 7
  • 52
  • 72
Qiulang
  • 10,295
  • 11
  • 80
  • 129