2017-09-04 41 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。但是,在具有兩個表視圖的非標準實現中,您無法使用它。所以不要。