【发布时间】:2009-02-23 17:59:09
【问题描述】:
有没有办法在操作表完全关闭之前呈现模态视图控制器视图?我在这里尝试这样做,但似乎回调必须在模态视图出现之前完成:
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (0 == buttonIndex) { // clicked 'Are you sure?' button
[self splashScreen:YES];
...
然后我基本上会这样做:
[[AppDelegate tabBarController] presentModalViewController:self.TMX_splashViewController animated:YES];
我的问题是我想回答“你确定吗?”操作表中的按钮,然后在我做一些工作(进行批量上传)时在我的模态视图控制器中显示进度指示器。但似乎行动表妨碍了;)
解决方案: 在展示模态视图控制器之前,我稍微延迟了一下。不确定我是否完全理解这一点,但似乎存在某种竞争条件,其中工作代码块会“领先于”模态表示代码。在稍作延迟后,它似乎起作用了。嗯,这很奇怪!
[self splashScreen:YES];
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval:0.75
target: self selector:@selector(waitForSplashTimer:) userInfo: nil repeats: NO];
【问题讨论】:
-
不确定这是否是“犹太洁食”,但我不得不稍微延迟一下,现在它可以工作了:[self splashScreen:YES]; NSTimer *定时器; timer = [NSTimer scheduledTimerWithTimeInterval:0.75 目标:自我选择器:@selector(waitForSplashTimer:) userInfo: nil repeats: NO];
标签: iphone objective-c cocoa-touch