ios - 快速 TableView Controller 不可滚动

标签 ios swift

这是我的代码:

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
    }
}

在我的 Storyboard中,我选择 Basic 作为单元格的样式。

我的问题是表格 View 不可滚动,我只能看到前 14 个玩家,如下所示:

enter image description here

更新 1

我将 print("\(indexPath.row)") 放在 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 方法上我可以看到只打印了 15 个值,其他 30 个在哪里?

更新2

在 TableView 上启用滚动 enter image description here

更新3

已启用用户交互,正如您在此处看到的

enter image description here enter image description here

最佳答案

这是你的答案。检查你的鼠标。在模拟器中,您应该点击屏幕并滚动。

关于ios - 快速 TableView Controller 不可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32455372/

相关文章:

xcode - 如何更改 NSTableHeaderView 的背景颜色而不隐藏列标题?

swift - 在词典词典中设置单个元素

swift - 为什么自己没有解决?

swift - 解析和 Swift 问题查询

ios - 自动滚动到 Swift 中 PFQueryTableViewController 中的下一个单元格

ios - 如何让 iOS VoIP 应用程序在响铃时服从“请勿打扰”?

ios - 使用自动布局创建的 UIView 的左右 16 像素边距

iPhone 多 View 与 iPad 单 View 共享一个 View Controller

ios - 在应用程序中存储大量照片的最佳方式是什么?

iOS >> 使用多个 Storyboard 时在 AppDelegate 中设置 UIWindow