EXC_BAD_ACCESS with viewWillTransitionToSize and Xcode 6.3
Asked Answered
O

1

4

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)
}
Outburst answered 22/4, 2015 at 18:19 Comment(2)
Any updates on this? I'm experiencing the same thing.Kalidasa
I read on the Apple forums that it is a bug. Workaround:Outburst
O
3

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")
    }
}
Outburst answered 6/5, 2015 at 20:53 Comment(2)
Unfortunately I get "coordinator == nil" every time in my Today Widget which prevents the crash but also prevents access to size which is my goal. Are you getting safeCoordinator set to a non nil value each time?Kalidasa
Sometimes it was nil. I dont understand itOutburst

© 2022 - 2024 — McMap. All rights reserved.