Any way to prevent UIActionSheet from being dismissed when user clicks a button in it?

*爱你&永不变心* 提交于 2019-12-11 16:16:33

问题


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.


回答1:


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.




回答2:


@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.



来源:https://stackoverflow.com/questions/8632944/any-way-to-prevent-uiactionsheet-from-being-dismissed-when-user-clicks-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!