Reputation: 481
I have a custom TableViewCell which contains the following code:
import Foundation
import UIKit
class MatchCell : UITableViewCell {
@IBOutlet var blueTeamLogoImageView: UIView
@IBOutlet var blueTeamNameShort: UILabel
@IBOutlet var blueTeamScore: UILabel
@IBOutlet var blueTeamStats: UILabel
@IBOutlet var blueTeamWinIndicator: UIView
@IBOutlet var redTeamLogoImageView: UIImageView
@IBOutlet var redTeamNameShort: UILabel
@IBOutlet var redTeamScore: UILabel
@IBOutlet var redTeamStats: UILabel
@IBOutlet var redTeamWinIndicator: UIView
init(style: UITableViewCellStyle, reuseIdentifier: String!) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
}
Now I try to add my MatchCell to my !GROUPED! (dont know if it makes any difference) UITableView. I've implemented:
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int func tableView(tableView: UITableView!, titleForHeaderInSection section: Int) -> String func numberOfSectionsInTableView(tableView: UITableView!) -> Int
and added: tableView.dataSource = self They are all returning the correct values, already checked that.
Now when I run my app... it looks like this: http://www1.xup.to/exec/ximg.php?fid=14474271
Here is my cellForRowAtIndexPath:
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
if self.lcsWeek {
let cell: MatchCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as MatchCell
var currentDay: Day = self.lcsWeek!.Days[self.lcsWeek!.getDayById(indexPath.section)]!
var currentMatch: Match = currentDay.matches[indexPath.row]
cell.blueTeamNameShort.text = currentMatch.blueTeamAcronym
cell.redTeamNameShort.text = currentMatch.redTeamAcronym
return cell
}
else {
return nil
}
}
It should look like this: http://www1.xup.to/exec/ximg.php?fid=19982127
I think the problem is located somewhere in the cellForRowAtIndexPath function... I hope someone can help me
Upvotes: 0
Views: 1386
Reputation: 895
You should implement this:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Your table has no information, how big those cells should be.
Upvotes: 2