Thanks in advance for the help!
I'm trying to use segmented control to change child views inside a container view on one of my view controllers. I found a good answer on SO about this and below was the following code:
@IBAction func segmentedControlChange(sender: AnyObject) {
var newController = storyboard?.instantiateViewControllerWithIdentifier(viewControllerIdentfiers[sender.selectedIndex]) as! UIViewController
let oldController = childViewControllers.last as! UIViewController
oldController.willMoveToParentViewController(nil)
addChildViewController(newController)
newController.view.frame = oldController.view.frame
transitionFromViewController(oldController, toViewController: newController, duration: 0.25, options: UIViewAnimationOptions.TransitionFlipFromRight, animations: {
() -> Void in
//nothing needed here
}, completion: { (finished) -> Void in
oldController.removeFromParentViewController()
newController.didMoveToParentViewController(self)
})
}
When I run it in the simulator and then click on the segmented control, I come up with THREAD 1: EXC_BAD_INSTRUCTION(code = EXC_l386_INVOP, subcode=0x0). I used story board identifiers on the view controllers as well.