2013-11-27 31 views
3

我有一个UIViewController我从中提出一个模态视图。SVProgressHUD显示在背景为莫代尔视图

[self presentViewController:modal animated:YES completion:nil]; 

它有两个UIBarButtonItems(名为取消保存)。我正在执行一些操作保存按钮水龙头。我在-saveButtonTapped方法上显示SVProgressHUD指标。

- (IBAction)saveButtonTapped:(id)sender 
{ 
    NSLog(@"Modal Save Pressed."); 
    [SVProgressHUD showWithStatus:@"Loading..."]; 
    // Some other code... 
} 

问题是指示器没有显示在我的ModalView前面。它开始动画,但在ModalView之后,不在前面。


正在发生的事情:

的UIViewController ===> SVProgressHUD ===> ModalView

我想要什么:

的UIViewController = ==> ModalView ===> SVPr ogressHUD


searched,但没有找到任何解决方案。

为什么会发生这种情况,以及如何解决这个问题?

+0

你可以给一些图片它是如何表示 – codercat

+0

@iDev:我不能,但我已经添加了代码,如果它可以帮助你。 – Bhavin

+0

你可以提供一些截图或一些额外的代码在你的模态控制器。 – Bordz

回答

0

最后,我需要使用NSThread来管理问题。

其实,我从我的-saveButtonTapped方法调用一个名为-postForEditDispatch的方法。我使用-detachNewThreadSelector:toTarget:withObject:创建了一个单独的线程,并试图在该线程上调用该方法。

示例代码:

- (IBAction)saveButtonTapped:(id)sender 
{ 
    NSLog(@"Modal Save Pressed."); 
    [SVProgressHUD showWithStatus:@"Loading..."]; 
    // Some other code... 

    [NSThread detachNewThreadSelector:@selector(postForEditDispatch:) toTarget:self withObject:nil]; 
} 
+0

我们应该在“postForEditDispatch”函数里面有什么? – LIH