views:

314

answers:

2

Hello,

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 ?

thanks,

regards,

r.

A: 

This is a bit of a hack but should work. Note that there is a good chance that this will result in your app not being accepted into the app store as you're messing around with the action sheet in ways Apple didn't intend.

Initially display the action sheet with both the 'Done' and 'Cancel' buttons. Before displaying the sheet hide the 'Done' button using its hidden property. To see how to access the 'Done' button see this question.

Then when you're hiding the UIActivityIndicatorView, also change the hidden property of both the 'Cancel' and 'Done' buttons, so that the 'Done' button becomes visible. If the 'Done' button appears in the wrong position move it by modifying its centre property.

pheelicks
yes, I saw this post that you're refering. thanks
mongeta
A: 

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

medopal
This is only a one time use, so another tap in de Done button wouldn't be too much :-) But I'm agree with you. How can I dismiss the ActionSheet wihtout using the Cancel button ?
mongeta
@mongeta, im updating my answer
medopal
Yes, I know I can dismiss using the call dismissWithClickedButton... but I only have one button:Cancel. If the user touchs the Cancel, I cancel the operation, and I don't want to use the same cancel method action for just closing the ActionSheet without cancelling the operation.thanks,r.
mongeta
I saw some apps that do this: Open an ActionSheet with a progress wheel and a Cancel button, once the operation has finished, they simply hide the progress bar, update the title and change the Cancel to Done.Don't know if they're using a custom view (I don't think so as the mimic is the same as the UI ActionSheet)...Just hope that this would be an easier thing ...:-)thanks,r.
mongeta