[英]swift table view controller is not scrollable
这是我的代码:
class PlayersNamesTableViewController: UITableViewController {
var players = [Player]()
let numberOfPlayers = 30
override func viewDidLoad() {
super.viewDidLoad()
loadPlayers()
}
func loadPlayers(){
for index in 0..<numberOfPlayers{
let player = Player(name: "Player \(index)")
players += [player]
}
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return players.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("playerCellIdentifier", forIndexPath: indexPath) as UITableViewCell
let player = players[indexPath.row]
cell.textLabel?.text = "\(player.name)"
return cell
}
}
在我的情节提要中,我选择“ Basic
作为单元格的样式。
我的问题是表格视图不可滚动,我只能看到前14个播放器,如下所示:
我将print("\\(indexPath.row)")
放在override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
方法上,我看到只打印了15个值,其他值在哪里30吗
如您在此处看到的,启用了用户交互
这是你的答案。 检查鼠标。 在模拟器中,您应该单击以进行屏幕滚动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.