Ios 如何覆盖代码中的序列类型?

Ios 如何覆盖代码中的序列类型?,ios,swift,uistoryboardsegue,Ios,Swift,Uistoryboardsegue,简单地说,我有一个从FirstViewController到SecondViewController的系列节目。 我从我的FirstViewController的两个位置在iPad和iPhone上调用它。可以,但有一种情况下,我需要将SecondViewController显示为.Popover 它不起作用 您知道如何在代码中覆盖情节提要中的序列吗?您应该使用自定义序列: 通过子类化UIStoryboardSegue类并重写prepare方法实现自定义segue。在“准备方法”中,根据您的案例,

简单地说,我有一个从FirstViewController到SecondViewController的系列节目。 我从我的FirstViewController的两个位置在iPad和iPhone上调用它。可以,但有一种情况下,我需要将SecondViewController显示为.Popover

它不起作用


您知道如何在代码中覆盖情节提要中的序列吗?

您应该使用自定义序列:

通过子类化UIStoryboardSegue类并重写prepare方法实现自定义segue。在“准备方法”中,根据您的案例,实现所有必需的行为控制器动画、演示等; 在interface builder中将您的segue类型从push更改为custom,并在类属性中选择您的实现,如下图所示
致以最良好的祝愿

您是否考虑过使用.Popover属性创建第二个segue。这意味着在prepareForSegue中不需要太多代码。
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
        }
    }
}