调用[selfmissModalViewControllerAnimated:YES]后UIView不出现;

发布于 2024-12-11 03:28:37 字数 807 浏览 0 评论 0原文

所以这个让我难住了......

我显示了一个导航控制器,按下按钮后它会向其父级发送一个 NSNotification 并执行:

-(void)dismissModalWithUpload:(NSNotification *)notification
{
    [self dismissModalViewControllerAnimated:YES];
    [self performSelectorInBackground:@selector(executeUpload:) withObject:notification];
}

模式对话框关闭,一切都很好。在随后的调用(executeUpload)中,我尝试取消隐藏包含进度指示器的视图以执行其他一些工作:

[self performSelectorOnMainThread:@selector(showProgressBar:) withObject:nil waitUntilDone:YES];

...问题是,直到executeUpload 中的任务完成后才会显示进度。我一直在尝试背景各种事情来使其发挥作用,但没有成功。有什么想法吗?

我还尝试使用以下命令来后台上传:

dispatch_queue_t myCustomQueue = dispatch_queue_create("com.freethinker.uploadQueue", NULL);

dispatch_async(myCustomQueue, ^{
    [self executeUpload:notification];
});

So this one has me stumped....

I show a navigation controller, which after pressing a button sends an NSNotification to it's parent which executes:

-(void)dismissModalWithUpload:(NSNotification *)notification
{
    [self dismissModalViewControllerAnimated:YES];
    [self performSelectorInBackground:@selector(executeUpload:) withObject:notification];
}

The modal dialog dismisses, everything is fine there. In the subsequent call (executeUpload) I try to unhide a view which contains a progress indicator to do some other work:

[self performSelectorOnMainThread:@selector(showProgressBar:) withObject:nil waitUntilDone:YES];

...the trouble is, the progress does not appear until the task in executeUpload is done. I have been trying to background various things to get this working, without any success. Any ideas out there ?

I have also tried to background the upload with:

dispatch_queue_t myCustomQueue = dispatch_queue_create("com.freethinker.uploadQueue", NULL);

dispatch_async(myCustomQueue, ^{
    [self executeUpload:notification];
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神经大条 2024-12-18 03:28:37

好吧,我终于弄清楚了。诀窍是在关闭模态视图控制器之前显示底层进度视图[progressBaseView setHidden:NO]。

其余的想法是正确的 - 所有繁重的工作都发生在后台,同时在主线程上更新 UI。

OK, So I finally got to the bottom of this. The trick is to show the underlying progress view [progressBaseView setHidden:NO] before dismissing the modal view controller.

The rest of the thinking is correct - all of the heavy lifting occurs in the background, while updating the UI on the main thread.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文