0
我的桌面佈局是這樣的,我有一個固定的搜索欄在桌面視圖的頂部。因此,搜索欄保持在頂部,並且不會與UITableView一起滾動。雖然我有我想要的佈局,但我的tableView沒有顯示單元細節(顯示空白)。請有人建議我去哪裏錯了?在桌面頂部鎖定搜索欄
我的佈局:
TestTableViewController
class TestTableViewController: UIViewController, UITableViewDelegate, UISearchBarDelegate{
var itemstore: ItemStore!
// Sets how many rows in the table view to display
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return itemstore.allItems.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Get a new or recycled cell
let cell = UITableViewCell(style: .value1, reuseIdentifier: "UITableViewCell")
let name = itemstore.allItems[indexPath.row]
cell.textLabel?.text = name
return cell
}
}
ItemStore
class ItemStore {
var allItems = ["Thanh", "David", "Tommy", "Maria"]
}
AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Create ItemStore instance
let itemStoreObject = ItemStore()
let itemController = window!.rootViewController as! TestTableViewController
itemController.itemstore = itemStoreObject
return true
}
你在Interface Builder中連接了表視圖數據源和委託嗎? – paulvs
請你能擴展你的問題。我不知道該怎麼做。 – tim
你IBOutlet你的桌面? 還檢查你連接tableview數據源和委託? – iUser