views:

921

answers:

1

Is there a way to present a modal view controller view before an action sheet has completely been dismissed? I'm trying to do it here but it seems that the callback has to complete before the modal view appears:

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{   
    if (0 == buttonIndex) {  // clicked 'Are you sure?' button
     [self splashScreen:YES];
...

And then I essentially do:

[[AppDelegate tabBarController] presentModalViewController:self.TMX_splashViewController animated:YES];

My problem is that I'd like to respond to an "Are you sure?" button in an action sheet and then show a progress indicator in my modal view controller while I do some work (do a batch upload). But it seems the action sheet is in the way ;)

SOLUTION: I put a slight delay before presenting the modal view controller. Not sure I understand this completely, but it seems that there was some sort of race condition where the working block of code would 'get ahead' of the modal presentation code. After putting a slight delay it seems to work. Um, this is odd!

[self splashScreen:YES];       
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval:0.75
     target: self selector:@selector(waitForSplashTimer:) userInfo: nil repeats: NO];
+2  A: 

You can also use -performSelector:withObject:afterDelay:, it's a little less code, and easier to read:

[self performSelector: @selector(waitForSplashTimer:) withObject: nil afterDelay: 0.75];
Ben Gottlieb