【发布时间】:2017-03-29 19:54:55
【问题描述】:
我在使用导航控制器连接到我的详细视图时遇到问题。
我正在使用表格视图来显示一些练习,当您单击练习时,您将进入详细视图,嵌入在导航控制器中 我删除了 Tableview,并添加了 3 个按钮,每个按钮都有自己的“显示”segue 到详细视图。它几乎可以工作,但它现在不使用我的导航控制器,这意味着视图只是呈现有点像模态演示。 我已经尝试在一个按钮上删除 segue 并替换为此操作:
@IBAction func strengthButton(_ sender: UIButton) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destination = storyboard.instantiateViewController(withIdentifier: "ExerciseViewController") as! ExerciseViewController
destination.componentaccessid = -1;
destination.openedFromUrl = false;
destination.exercise = self.strengthexercise
destination.exercisetype = .strength
self.navigationController?.present(destination, animated: true, completion: nil)
}
但这完全一样。
我有一个准备函数:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let identifier = segue.identifier,
let destination = segue.destination as? ExerciseViewController{
destination.componentaccessid = -1;
destination.openedFromUrl = false;
switch identifier{
case "strengthsegue":
destination.exercise = self.strengthexercise
destination.exercisetype = .strength
case "rangesegue":
destination.exercise = self.rangeexercise
destination.exercisetype = .range
case "combinedsegue":
destination.exercise = self.combinedexercise
destination.exercisetype = .combined
default:
print("Nothing")
}
}
}
【问题讨论】:
-
self.navigationController?.pushViewController -
哦,谢谢。为什么 segues 不能通过导航控制器显示
-
在故事板检查器中检查其
kind,应该是Show (e.g. Push)