我只需要从FirstViewController
到SecondViewController
有一段显示。
我在FirstViewController
的两个地方用iPad和iPhone拨打电话。没关系,但在一种情况下,我需要将SecondViewController
作为.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
}
}
}
它不起作用。
如何在代码中覆盖故事板中的segue类型?