PDA

View Full Version : How to Redraw View after UIActionSheet




belsokar
Aug 4, 2008, 07:00 PM
So I currently am using a UIViewController to manage a view.

On that view, I have a button that opens up a UIActionSheet.

After setting that Action sheet, I have some code in my ViewWillAppear method that doesn't get called on a UIActionSheet close.

I have figured out how to reload a tableview, but for some reason, there doesn't seem to be something similar for a standard view. I basically want to refresh the view so it calls out the ViewWillAppear code segment on my page.

thanks!



kainjow
Aug 4, 2008, 08:25 PM
Use the UIActionSheet delegate methods to determine when the alert has dismissed, and then you can update a view via the setNeedsDisplay method (or just call viewWillAppear manually).

belsokar
Aug 5, 2008, 12:18 PM
Thanks, I didn't catch those actionSheet delegates the first time.

So I setup the following action sheet delegate:

didDismissWithButtonIndex:

and that delegate is successfully called, and I tried the following:

[self.view setNeedsDisplay];

However, that doesn't seem to force a re-display, as I would expect my viewWillAppear to be called, and it isn't.

Any ideas? I haven't tried calling viewWillAppear manually, but I will try that as well I suppose.

kainjow
Aug 5, 2008, 03:56 PM
Well, what's actually changing that needs redisplaying? What are you expecting it to do?

belsokar
Aug 5, 2008, 06:00 PM
Well, what's actually changing that needs redisplaying? What are you expecting it to do?

I have a dual mode button. In state 1, the name of the button is "Button 1" for example. When I press the button the first time, it displays the UIActionSheet. Depending on the selection within the ActionSheet, I then change the state of the button to to state 2, with new text "Button 2".

If I navigate away from the view and back, it is fine because I declare the title text for the button in the ViewWillAppear method. Upon exiting the action sheet however, I am just trying to force the view to redraw/reload so that the new button state is reflected.

thanks!

dekelver
Oct 9, 2008, 09:02 AM
I'm looking to do the same thing, I've got a view that I want a user to click to reveal something underneath it. After about 2 seconds I want it to switch back to what it was, but I don't want to stop the users from doing other things in the mean time. And I want them to see an animation when they click it, and when it shifts back.

I've got the NSTimer set up to handle the switch back, and the method is firing correctly after 2 seconds. But the UI doesn't update. I need some way of forcing the UI to redraw itself, or forcing it to update when the 2 seconds are done.

Help?