我有一個具有嵌入式NavigationController的TableViewController。還有一個ViewController添加新的位置到tableview。 這顯示的故事板 從segue中顯示視圖時Navbar消失
相關章節當用戶點擊一個選擇位置存在通過NavigationController一個SEGUE行動的LocationChoiceTableViewController ...顯示器的縮短版...
正如你可以看到我的導航欄顯示兩個按鈕來添加或編輯列表。如果用戶單擊添加segue操作將它們帶到AddLocationViewController ... 用戶添加新位置的詳細信息,然後單擊具有segue操作的添加返回到LocationChoiceTableViewController以傳回作爲單個連接字符串輸入的值newLocationtoPass)
的viewDidLoad中在LocationChoiceTableViewController類有....
override func viewDidLoad() {
super.viewDidLoad()
self.resultsController.tableView.dataSource = self
self.resultsController.tableView.delegate = self
if let savedLocations = defaults.objectForKey("locations") as? NSData {
locations = NSKeyedUnarchiver.unarchiveObjectWithData(savedLocations) as![String]
}
if newLocationtoPass != nil {
// we have a new location passed via segue from AddNewLocationViewController
//add new location to locations array and sort
insertSorted(&locations, newItem: newLocationtoPass)
// save location array to NSUserDefaults
saveLocationArray()
}
self.navigationController?.setNavigationBarHidden(false, animated: true)
self.navigationItem.leftBarButtonItem = self.editButtonItem()
self.searchController = UISearchController(searchResultsController: self.resultsController)
self.tableView.tableHeaderView = self.searchController.searchBar
self.searchController.searchResultsUpdater = self
self.searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
}
如果newLocationtoPass是哪個不爲空將插入值到數組(在正確的排序位次),並保存到數組NSUserDefaults的。 ..所有這些工作如下面的屏幕截圖所示...
我的問題是,我已經失去了我的導航欄與編輯/添加按鈕。我添加了行self.navigationController?.setNavigationBarHidden(false, animated: true)
,但從AddLocationViewController返回時,導航欄不顯示。
任何幫助解決這個問題將不勝感激。
對不起...沒有改變視圖顯示方式 – Mych