Reputation: 61840
Simply I have one segue of kind Show from FirstViewController
to the SecondViewController
. I call it on iPad and iPhone from two places of my FirstViewController
. It is OK, but in one case I need to present SecondViewController
as a .Popover
.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let secondViewController = segue.destinationViewController as? SecondViewController {
if let cell = sender as? UITableViewCell, indexPath = tableView.indexPathForCell(cell) {
let student = fetchedResultsController.objectAtIndexPath(indexPath) as! Student
secondViewController.schoolClass = schoolClass
secondViewController.student = student
} else {
secondViewController.modalPresentationStyle = .Popover
secondViewController.schoolClass = schoolClass
let popoverPresentationController = studentFormViewController.popoverPresentationController
popoverPresentationController!.delegate = self
popoverPresentationController?.permittedArrowDirections = .Up
popoverPresentationController?.barButtonItem = addStudentBarButtonItem
}
}
}
It doesn't work.
How can I override kind of segue from storyboard in code?
Upvotes: 0
Views: 316
Reputation: 394
You should use custom segues:
Best regards!
Upvotes: -1