【发布时间】:2014-09-04 07:03:33
【问题描述】:
我有一个自定义的 TableViewCell,其中包含以下代码:
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)
}
}
现在我尝试将我的 MatchCell 添加到我的 !GROUPED! (不知道它是否有任何区别) UITableView。我已经实现了:
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int func tableView(tableView: UITableView!, titleForHeaderInSection section: Int) -> String func numberOfSectionsInTableView(tableView: UITableView!) -> Int
并添加:tableView.dataSource = self 他们都返回了正确的值,已经检查过了。
现在当我运行我的应用程序时......它看起来像这样:http://www1.xup.to/exec/ximg.php?fid=14474271
这是我的 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
}
}
应该是这样的:http://www1.xup.to/exec/ximg.php?fid=19982127
我认为问题出在 cellForRowAtIndexPath 函数的某个地方...希望有人可以帮助我
【问题讨论】:
标签: ios uitableview swift