2009-02-23 30 views
0

是否有一种方法可以在行动表完全被解除之前呈现模态视图控制器视图?我想在这里做,但它似乎有回调出现前的模态视图来完成:行动表之前的模态视图完全解除

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

然后我基本上是做:

[AppDelegate中tabBarController] presentModalViewController:self.TMX_splashViewController动画:YES];

我的问题是,我想回应一个“你确定吗?”按钮,然后在我的模式视图控制器中显示进度指示器,同时做一些工作(做批量上传)。但它似乎是行动表的方式;)

解决方案: 我提出了一个小的延迟之前呈现模态视图控制器。我不知道我完全理解这一点,但似乎有某种竞争条件,代码的工作块会“超前”模态表示代码。稍微延迟后,似乎工作。呃,这很奇怪!

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

不知道这是“犹太”,但我不得不把现在有效: [self splashScreen:YES]; \t \t \t \t \t \t NSTimer * timer; \t \t计时器= [的NSTimer scheduledTimerWithTimeInterval:0.75 \t \t \t \t \t \t \t \t \t \t \t \t目标:自选择器:@selector(waitForSplashTimer :) USERINFO:无重复:NO]; – Rob 2009-02-23 18:57:41

回答

2

您还可以使用-performSelector:withObject:afterDelay:,这是一个有点更少的代码,并且更易于阅读:

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