我有一个UITableView
在UIViewController
的问题。我的表显示了一些行,我不知道为什么。它应该显示所有的行。UITableView显示一些行
class TableViewController: UIViewController,UITableViewDelegate, UITableViewDataSource {
let cellIdentifier = "testCell"
override func viewDidLoad() {
super.viewDidLoad()
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return 20
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! TableViewCell
cell.lableName.text = "Hello man"
return cell
}
}
是你的细胞高度是不是默认的细胞高度? –
您没有在数据源方法'cellForRowAtIndexPath'中配置数据,那么tableview如何显示数据! – Lion
你输入的行数是20,所以表视图创建20行 –