【发布时间】:2016-02-14 12:37:54
【问题描述】:
所以这就是正在发生的事情:
我在图像视图中添加了红色背景色,这样您就可以看到它已经过去了多少。
我试过tableView(:willDisplayHeaderView:),我试过检查Subviews,我试过AspectFit,AspectFill,&ScaletoFill但是UIImageView不断超越他们原来的界限,我没有'不明白为什么。
这是我UITableViewController的一些代码:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("scheduleCell", forIndexPath: indexPath) as! ScheduleTableViewCell
let eventList = schedule?.schedule[dayOfWeek[indexPath.section]]!
let event = eventList![indexPath.row]
cell.labelEvent.text = event.act.rawValue
cell.labelTime.text = "\(event.getTime(event.start)) - \(event.getTime(event.end))"
return cell
}
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let tableViewCell = cell as! ScheduleTableViewCell
let eventList = schedule?.schedule[dayOfWeek[indexPath.section]]!
let event = eventList![indexPath.row]
tableViewCell.imageView?.image = UIImage(named: "\(schedule!.potato.mode)-\(event.act.rawValue)")
tableViewCell.imageView?.backgroundColor = UIColor.redColor()
tableViewCell.imageView?.contentMode = .ScaleAspectFit
}
这是我的自定义单元类:
class ScheduleTableViewCell: UITableViewCell {
@IBOutlet weak var imageEvent: UIImageView!
@IBOutlet weak var labelEvent: UILabel!
@IBOutlet weak var labelTime: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
【问题讨论】:
标签: xcode swift uitableview uiimageview nslayoutconstraint