ios - SVProgressHUD 在模态视图的背景中显示

标签 ios iphone objective-c ios7 svprogresshud

我有一个 UIViewController,我从中呈现模态视图。

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

它有两个 UIBarButtonItems(名为 CancelSave)。我正在对 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/

相关文章:

ios - RestKit复杂而简单的JSON RKObjectMapping几乎可以工作,但是

ios - 安全地忽略 Carthage.resolved?

应用程序中的 ios-thread 1 exc_bad_instruction 错误

ios - 根据包含背景图像的文本的宽度拉伸(stretch) UILabel 的宽度

iphone - 将低于最新版本的 IOS 版本安装到设备

iphone - 没有输入 Switch 语句?

objective-c - OCMock,为什么我不能期待协议(protocol)上的方法?

ios - 使用NSURL和NSJSON运行应用程序时出现“NSInvalidArgumentException”

php - 从 php 脚本返回数组到 Swift 时,JSON_encode 导致错误

iphone - 应用内购买完成后保存下载的内容