我有一个 UIViewController
,我从中呈现模态视图。
[self presentViewController:modal animated:YES completion:nil];
它有两个 UIBarButtonItems
(名为 Cancel 和 Save)。我正在对 Save 按钮点击执行一些操作。我在 -saveButtonTapped
方法上显示 SVProgressHUD
指示器。
- (IBAction)saveButtonTapped:(id)sender
{
NSLog(@"Modal Save Pressed.");
[SVProgressHUD showWithStatus:@"Loading..."];
// Some other code...
}
问题是指示器没有显示在我的 ModalView
前面。它开始动画,但在 ModalView
之后,而不是在前面。
发生了什么:
UIViewController ===> SVProgressHUD ===> ModalView
我想要什么:
UIViewController ===> ModalView ===> SVProgressHUD
我searched但没有找到任何解决方案。
为什么会发生这种情况以及如何解决这个问题?
最佳答案
最后,我必须使用 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];
}
关于ios - SVProgressHUD 在模态视图的背景中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20242406/