[英]swift 3 Second TableView segue not showing in Navigation Controller
編輯2:在底部添加了一個半解。 仍然有完整的解決方案
編輯1:添加了圖像。
我需要幫助修復第二個和第三個tableview之間的導航。
我有一個導航控制器和三個表格視圖。 前兩個顯示很好,因此在第一個表視圖中單擊動態表視圖單元>會移到第二個表視圖。 但是,在情節提要中設置的第二個tableview單元格chevron>(附件:Disclosure Indicator)在運行時不會顯示,因此單擊它不會移動到第三個tableview。 我需要解決此問題的幫助。
在每種情況下,我都按Ctrl +鍵將單元格鏈接到情節提要中的下一個表格視圖,如圖所示,並准備在先前的表格視圖控制器中進行監視。 但是,只有一部作品和另一部作品似乎是孤立的。
如果您可以提出一個清單,以確保導航控制器可以在三個表視圖中正常工作,那將很有幫助。 不知道要顯示什么代碼,所以我將同時發布這兩個命令。 但這可能不是問題,所以我不知道。
第一張Tableview Weeks作品進入第二張Tableview Leagues。 根據單擊的內容加載json文件。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "toLeagues"
{
let leaguesController = segue.destination as! LeaguesViewController
// pass the selected row
let selectedRow = self.tableView.indexPath(for: sender as! UITableViewCell)!.row
if selectedRow == 0
{
leaguesController.weekFileName = "sports_week_1"
}
else
{
leaguesController.weekFileName = "sports_week_2"
}
}
但是第二個Tableview聯賽無法進行第三個TableView游戲
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "toGames"
{
let gamesController = segue.destination as! GamesViewController
// pass the selected row
let selectedRow = self.tableView.indexPath(for: sender as! UITableViewCell)!.row
gamesController.gameName = selectedRow.description
}
}
編輯1:添加的圖像:
編輯2:一半解決方案
我找到了解決辦法。 現在,菜單項將打開新視圖,只有該V形符號出現在事實之后。 didSelectRowAt直接添加缺少的公開指示器,然后轉到新的視圖控制器。 找不到帶有IndexPath的viewWillAppear,所以我選擇了didSelectRowAt。 至少在單擊時有效。 只是在初始加載時缺少披露指標。 在視圖運行之前如何加載附件類型?
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .disclosureIndicator
// force menu to move to GamesViewController
let myGamesView = self.storyboard!.instantiateViewController(withIdentifier: "gamesView")
self.navigationController?.pushViewController(myGamesView, animated: true)
}
嘗試在cellForRowAt
而不是didSelectRowAt
設置accessoryType
。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "yourIdentifier") as! YourCustomCell
//Your other code
cell.accessoryType = .disclosureIndicator
return cell
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.