Marco Dinatsoli
Marco Dinatsoli

Reputation: 10570

swift table view controller is not scrollable

this is my code:

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

in my storyboard, i select Basic for the style of the cell.

My problem is that the table view is not scrollable, i just can see the first 14 players, like this:

enter image description here

Update 1

I put print("\(indexPath.row)") on the override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { method and I can see that there are just 15 values being printed, where are the other 30?

Update2

Scroll is enabled on the table view enter image description here

Update3

User Interaction is enabled, as u see here

enter image description here enter image description here

Upvotes: 0

Views: 1878

Answers (1)

Candost
Candost

Reputation: 1029

Here is your answer. Check your mouse. In simulator you should click to screen and scroll.

Upvotes: 4

Related Questions