EXC_BAD_ACCESS与viewWillTransitionToSize和Xcode 6.3

时间:2015-04-22 18:19:05

标签: ios xcode ios8-today-widget today-extension

此代码曾用于我们今天的扩展,但现在EXC_BAD_ACCESS使用Xcode 6.3。什么是新问题?

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 个答案:

答案 0 :(得分:3)

有人向我提到他们认为这是一个Apple bug。这是一种解决方法(或解决方案):

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")
    }
}