调用[selfmissModalViewControllerAnimated:YES]后UIView不出现;
所以这个让我难住了......
我显示了一个导航控制器,按下按钮后它会向其父级发送一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我终于弄清楚了。诀窍是在关闭模态视图控制器之前显示底层进度视图[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.