2016-04-23 22 views
0

NavigationControllerが埋め込まれたTableViewControllerがあります。新しい位置をテーブルビューに追加するViewControllerもあります。ユーザがLocationChoiceTableViewControllerにNavigationController介してセグエ作用がある選択した場所をクリックすると これはストーリーボード enter image description hereビューが表示されたときにNavbarが消える

の要部を示し...ディスプレイの短縮バージョンは...です

enter image description here

ご覧のとおり、ナビゲーションバーには2つのボタンが表示され、リストを追加または編集できます。ユーザーがAddをクリックすると、SegueアクションはAddLocationViewControllerに移動します。 enter image description here ユーザーは、新しい場所の詳細を追加して、Segueアクションを持つAddをクリックしてLocationChoiceTableViewControllerに戻し、単一の連結文字列として入力された値を戻しますLocationChoiceTableViewControllerクラスのnewLocationtoPass)

のviewDidLoadは.... newLocationtoPassがnullでない場合

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 

} 

が正しいソート位置(配列に値を挿入)とNSUserDefaultsに配列を保存しますました。 ..これはすべて下のスクリーンショットに示すように動作します... enter image description here

私の問題は、編集/追加ボタンでナビゲーションバーを失ったことです。私はself.navigationController?.setNavigationBarHidden(false, animated: true)という行を追加しましたが、AddLocationViewControllerから戻ると、navbarが表示されません。

この問題を解決するための助けがあれば幸いです。

答えて

0

が固定..あなたを助けるかもしれキャンセルからのようセグエアクション...私は私のストーリーボードを変更しましたAddLocationViewControllerのAddボタンは、LocationChoiceTreeViewControllerではなくNavigationControllerに送られました。

enter image description here

0

はself.navigationControllerを書き込もう.setNavigationBarHidden(アニメーション、偽:真)?viewWillAppearで...これは

+0

申し訳ありません...表示方法の変更はありません – Mych

関連する問題