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
}