Я населяю UITableView
с изображениями, выбранными пользователем. Я бы хотел, чтобы миниатюры в ячейках таблицы были одинакового размера, не влияя на соотношение сторон, чтобы не растягивать/перекосить изображения, что звучит для меня как ScaleAspectFill
, однако ни один из вариантов UIViewContentMode
, похоже, не имеет эффекта , Там мне противоречивые методы, примечание heightForRowAtIndexPath
, но удаление этого делает мои ячейки слишком маленькими. Ниже приведены мои методы didSelectRowAtIndexPath
и heightForRowAtIndexPath
, а также снимки экрана из симулятора моего текущего кода (с использованием изображений симулятора). Любая помощь приветствуется. UITableViewCell ImageView не масштабируется правильно?
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//sets cell based on meme in array
let cell = tableView.dequeueReusableCellWithIdentifier("memeCell") as! UITableViewCell
let meme = self.memes[indexPath.row]
// Set the name and image
cell.textLabel?.text = meme.topText + " " + meme.bottomText
cell.imageView?.frame = CGRectMake(0, 0, 200, 100)
cell.imageView?.contentMode = UIViewContentMode.ScaleToFill //ScaleAspectFill is best, ScaleToFill used to exagerate that its not working
//cell.imageView?.backgroundColor = UIColor.grayColor() //legacy code, will be removed at commit
cell.imageView?.image = meme.origImage
return cell
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
//cell row won't be large enough unless this method is called
return 75.0
}