2016-04-23 31 views
0

我有一个具有嵌入式NavigationController的TableViewController。还有一个ViewController添加新的位置到tableview。 这显示的故事板 enter image description here从segue中显示视图时Navbar消失

相关章节当用户点击一个选择位置存在通过NavigationController一个SEGUE行动的LocationChoiceTableViewController ...显示器的缩短版... enter image description here

正如你可以看到我的导航栏显示两个按钮来添加或编辑列表。如果用户单击添加segue操作将它们带到AddLocationViewController ... enter image description here 用户添加新位置的详细信息,然后单击具有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的。 ..所有这些工作如下面的屏幕截图所示... enter image description here

我的问题是,我已经失去了我的导航栏与编辑/添加按钮。我添加了行self.navigationController?.setNavigationBarHidden(false, animated: true),但从AddLocationViewController返回时,导航栏不显示。

任何帮助解决这个问题将不胜感激。

回答

0

固定......我改变了我的故事板,以便从SEGUE行动取消并且AddLocationViewController上的Add按钮转到NavigationController而不是LocationChoiceTreeViewController。

enter image description here

0

尝试写self.navigationController .setNavigationBarHidden(假,动画:真)?在viewWillAppear中。这可能会帮助你..

+0

对不起...没有改变视图显示方式 – Mych