本文介绍了当segue是模态时,performSegueWithIdentifier非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的表视图,我在表视图上处理select操作。此操作遵循segue。
I have a simple table view where I handle the select action on the table view. This action follows a segue.
如果segue是 push
segue,则立即显示下一个视图。
如果segue是模态
segue,则下一个视图:
If the segue is a push
segue, the next view shows immediately.If the segue is a modal
segue, the next view either:
- 需要6秒左右才能显示
- 如果我再次点击(第二次点击)立即显示
我试着四处寻找一些想法,但似乎没有一个适用于我的情况。特别是:
I tried looking around for some ideas, but none seem applicable to my situation. In particular:
- 我在主UI线程上执行segue
- 我的观点是非常简单(因此在
viewDidLoad
中没有问题)。此外,当seguepush
时,它显示近乎瞬时显示加载目标视图没有问题 - 我尝试过将
nil
传递给发件人
;同样的效果。
- I'm performing the segue on the main UI thread
- My view is very simple (so there's no issue in
viewDidLoad
). Plus the fact that it shows up near instantaneous when the segue ispush
indicates that there is no problem loading the target view - I tried passing
nil
to thesender
; same effect.
有没有人对此有任何想法?
Does anyone have any ideas on this?
推荐答案
相信我并尝试一下。我曾经遇到过这个问题几次。
Trust me and try this. I have run into this problem a few times.
在Swift 2中:
dispatch_async(dispatch_get_main_queue(),{
self.performSegue(withIdentifier:mysegueIdentifier,sender: self)
})
或Swift 3:
DispatchQueue.main.async {
self.performSegue(withIdentifier: mysegueIdentifier,sender: self)
}
正如所讨论的那样和。
这篇关于当segue是模态时,performSegueWithIdentifier非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!