Title: Present Modal View before Action Sheet completely dismissed
Tags: iphone;objective-c;cocoa-touch
Question: 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];
Comment: Not sure if this is 'kosher', but I had to put a slight delay and it now works:
[self splashScreen:YES];
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval:0.75
target: self selector:@selector(waitForSplashTimer:) userInfo: nil repeats: NO];

Here is the accepted answer: 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];


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2009:00:02/23/09', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<iphone><objective-c><cocoa-touch>', 'Title': 'Present Modal View before Action Sheet completely dismissed', 'ViewCount': 1555, 'id': 578638, 'user_AboutMe': '<p>Senior UI/UX Developer at Mavenlink. Love to build products that make folks lives easier. Also, host of The SVG Immersion Podcast:\n<a href="http://apple.co/1BvrZtV" rel="nofollow">http://apple.co/1BvrZtV</a></p>\n', 'user_AccountId': 163761.0, 'user_DisplayName': 'Rob', 'user_Reputation': 4033.0, 'user_Views': 508.0, 'user_id': 386102.0}}