[英]How to override kind of segue in code?
简而言之,我有一个从FirstViewController
到SecondViewController
Show 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?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.