0

I have a very basic layout. I just want a single cell to show up in my uitableview. I asked a question with this same problem (Swift Cells Not Displaying), but now I have simplified my code to the very basics.

Problem: The cell just won't show up. If I set the number of rows to 5, it will show up on the third cell but none of the others. I have the talbleview connected properly. I have the cell identifier named correctly, and the height of the cell is not the problem.

Heres my code:

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return 200.0
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell: ProfileTableViewCell = tableView.dequeueReusableCellWithIdentifier("profileTopCell", forIndexPath: indexPath) as! ProfileTableViewCell

    cell.profilePic.image = UIImage(named: "profileImagePlaceholder")

    cell.topView.backgroundColor = UIColor(red: 0, green: 155.0/255.0, blue: 0, alpha: 1)
    cell.nameLabel.text = PFUser.currentUser()!.objectForKey("Name") as? String
    cell.usernameLabel.text = PFUser.currentUser()!.objectForKey("username") as? String
    let friendNumber = PFUser.currentUser()!.objectForKey("numberOfFriends") as? Int
    if friendNumber != 1{
        cell.numberOfFriendsLabel.text = "\(friendNumber!) Friends"
    }else{
        cell.numberOfFriendsLabel.text = "1 Friend"
    }    

    return cell
}
Community
  • 1
  • 1
user3783946
  • 61
  • 1
  • 6

1 Answers1

0

Thanks to Jeremy Andrews (https://stackoverflow.com/a/31908684/3783946), I found the solution:

"All you have to do is go to file inspector - uncheck size classes - there will be warnings etc.run and there is the data - strangely - go back to file inspector and check "use size classes" again, run and all data correctly reflected. Seems like in some cases the margin is set to negative."

It was just a bug.

Community
  • 1
  • 1
user3783946
  • 61
  • 1
  • 6