0
我在改變segues以顯示或呈現ViewController時遇到了一些問題。 該代碼工作從segues到show/present view controller
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let noteDetailViewController = segue.destination as! NoteViewController
var selectedNote: Note?
if segue.identifier == "ShowDetail" {
if let selectedNoteCell = sender as? NoteTableViewCell {
let indexPath = tableView.indexPath(for: selectedNoteCell)!
selectedIndexPath = indexPath
if !searchIsEmpty() {
selectedNote = filteredNotes[indexPath.row]
} else {
selectedNote = notes[indexPath.row]
}
}
} else if segue.identifier == "RemindLater" {
if let note = notificationNote?.copy() as? Note {
selectedNote = note
}
}
noteDetailViewController.note = selectedNote?.copy() as? Note
noteDetailViewController.oldNote = selectedNote?.copy() as? Note
noteDetailViewController.isFiltered = isFiltered
resultSearchController.searchBar.isHidden = true
}
呼籲通過
vc.performSegue(withIdentifier: "RemindLater", sender: self)
我試圖做一個FUNC有異曲同工之妙,但對於使用顯示/本發明的方法。 看起來像這樣
func remindLater() {
if let note = notificationNote?.copy() as? Note {
noteToEditing = note
noteViewController.transitioningDelegate = self
noteViewController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
noteViewController.modalTransitionStyle = UIModalTransitionStyle.coverVertical
noteViewController.note = noteToEditing?.copy() as? Note
noteViewController.oldNote = noteToEditing?.copy() as? Note
noteViewController.isFiltered = isFiltered
resultSearchController.searchBar.isHidden = true
present(noteViewController, animated: true, completion: nil)
//show(noteViewController, sender: self)
}
}
但它不起作用。當我在viewDidLoad方法中設置我的視圖控制器上的對象(在調用remindLater方法後),我發現像UIDatePicked和其他所有對象等於零。這不是像使用segue這樣的。我究竟做錯了什麼?
有沒有辦法做到這一點,而不使用賽格瑞方法準備? – L1GhTUA