The code you show isn't enough to know what the error is. The error is shown because you are trying to animate 2 different view controllers at the same time (one being dismissed and one being shown). To avoide the issue you can:
1. Wait until one animation is complete before starting the next
Or
2. Run one of the changes (probably the dismissal) without animation