2017-09-04 43 views
-1

我更新Xcode和我更新我的应用程序到iOS 11做出的导航栏响应两个tableviews

iOS的11的新资源嵌入在一个navigationItem searchController。 下面的代码显示一切我做到了到现在为止

import UIKit 

class BKJPrincipal: UIViewController, UISearchResultsUpdating, 
UITableViewDelegate, UITableViewDataSource { 

@IBOutlet weak var tableView: UITableView! 
@IBOutlet weak var tableView1: UITableView! 

override func viewDidLoad() { 
    super.viewDidLoad() 

    self.view.backgroundColor = UIColor.white 
    title = "Teste" 

    self.navigationController?.navigationBar.prefersLargeTitles = true 

    let search = UISearchController(searchResultsController: nil) 
    search.searchResultsUpdater = self 
    self.navigationItem.searchController = search 

} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Dispose of any resources that can be recreated. 
} 

func updateSearchResults(for searchController: UISearchController) { 

} 

func numberOfSections(in tableView: UITableView) -> Int { 
    return 1 
} 

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return 3 
} 

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

    var cell:UITableViewCell? 

    if tableView == self.tableView { 
     cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) 

    } 

    if tableView == self.tableView1 { 
     cell = tableView.dequeueReusableCell(withIdentifier: "cell1", for: indexPath) 

    } 

    return cell! 
} 

我已经超出了这个唯一的一点是我的故事板与NavigationController在两个表视图组成视图控制器嵌入。

一切工作正常(代表,数据源,cellForRow ...),但我需要这两个导航条的moviment发生在这两个表。

下面的例子显示了今天发生了什么。

https://photos.app.goo.gl/Qvthenter image description here

+0

请用适当的细节解释你的问题,从你想要什么,你做了什么,你坚持什么点。这将吸引更多的用户,您很快就会得到适当的答案。无需发布链接。 –

+0

欢迎来到SO。请阅读https://stackoverflow.com/help/how-to-ask。这个问题是关于SO的话题,除非你详细提供了你已经尝试过的东西,什么不起作用,并且至少显示你的代码和结构。截图并没有多说它是如何编码的。祝你好运:) – 2017-09-04 17:12:15

+0

显示你的一些工作,你的代码更好的答案。 –

回答

0

iOS的11的新的资源在navigationItem

真正嵌入searchController。但是,在具有两个表视图的非标准实现中,您无法使用它。所以不要。