Search code examples
iphoneuiactionsheet

Change UIActionSheet after doing it's job


I have to import some XML data into my app.

Now I open a UIActionSheet and add as a subview a UIActivityIndicatorView. Initially I show a progress wheel and a button with 'Cancel'.

When the XML has been imported, I want to hide the progress wheel (this it's easy) and change the button into a 'Done' button, all in the same UIActionSheet.

What I'm doing now is closing the UIActionSheet with the option dismissWithClickedButtonIndex, but I don't like this way because it's the same as pressing 'Cancel', and then I show an UIAlertView displaying "All data has been imported".

Is this possible ?


Solution

  • You shouldn't be doing that, when it loads correctly just dismiss the ActionSheet. On the other hand if an error occurs then display an alert.

    Think about the user who will use the app multiple times a day, a Done message each time will be a waste of time.

    UPDATE
    As i understand your goal is to use the ActionSheet just as a popup (with Cancel ability), if so, just call dismissWithClickedButtonIndex:animated: when your XML loading is done. If its successful then just call the dismiss method, if its unsuccessful then call the dismiss and popup an alert