EXC_BAD_ACCESS with viewWillTransitionToSize and Xcode 6.3

好久不见. 提交于 2019-12-23 12:43:06

问题


This code used to work in our today extension, but now EXC_BAD_ACCESS with using Xcode 6.3. What is the new problem?

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
    coordinator.animateAlongsideTransition({ context in
        self.tableView.frame = CGRectMake(0, 0, size.width, size.height)
        }, completion: nil)
}

回答1:


Someone mentioned to me they think this is an Apple bug. Here's a workaround (or the solution):

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator)
{
    super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)

    if let safeCoordinator = coordinator as UIViewControllerTransitionCoordinator?
    {
        println("coordinator != nil")
        safeCoordinator.animateAlongsideTransition({ context in
            self.tableView.frame = CGRectMake(0, 0, size.width, size.height)
            }, completion: nil)

    }
    else
    {
        println("coordinator == nil")
    }
}


来源:https://stackoverflow.com/questions/29805843/exc-bad-access-with-viewwilltransitiontosize-and-xcode-6-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!