Xcode迅速Segue动画停止工作 - Xcode swift Segue animation stops working

- 此内容更新于:2015-12-13
主题:

我有segue变化时改变后退和前进通过视图,但一段时间后停止动画和瞬间变化。这个seguejmaki同样,我segue通过故事板工作时完全可以这样做。这是我使用的所有代码改变场景,我准备segue方法是空的。我用一个UI视图控制器

原文:

I have a segue that animates when changing back and forward through views, but after a while it stops animating and instantly changes.

This segue is programatic, I have segues that work perfectly fine when doing it through a storyboard.

func MoreInfo(sender: customButton!) {
    var nextPage: activityViewController = self.storyboard?.instantiateViewControllerWithIdentifier("activityPopOver") as activityViewController

    nextPage.model = sender.model
    nextPage.coordinate = self.coordinate

    self.navigationController?.pushViewController(nextPage, animated: true)

}

that's all the code I'm using to change scenes, my prepare for segue method is empty aswell. I am using a UI view controller aswell

解决方案:
发现这是与我的线程!有东西我不得不呼吁主线程在页面上我移动,我不知道为什么它影响了动画视图控制器之间移动时。所有我做的是编辑代码调用主线程上几行
原文:

Figured out that it was something to do with my threading! There was something I had to call on the main thread on the page I was moving to, I have no idea why it affected the animation when moving between view controllers. All I did was edit my code to call a few lines on the main thread

           dispatch_async(dispatch_get_main_queue(), {
                    // DO SOMETHING ON THE MAINTHREAD

                    var activity: ActivityBlock = ActivityBlock(screenWidth: self.infoView.frame.size.width, screenHeight: CGFloat(100), index: self.i, scrollRect: self.relatedActivites.frame, activity: app)

                    self.relatedActivites.contentSize = CGSizeMake(CGFloat(self.relatedActivites.frame.size.width * CGFloat((self.i + 1))), 100)
                    self.i++
                    self.relatedActivites.addSubview(activity.view)
           })