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