0
xcode/swiftの新機能です。私はiPhone 4インチの画面でUITableViewCellのUIImageViewを置き換える問題があります。私は3で正しい画像を埋め込んでいます:Assets.xcassetsで640,750,1242ピクセルの幅。uitableviewcell uiimage 4インチiphoneの自動レイアウト問題
TableViewとContentViewの制約[xCodeから後続スペースへ、先頭スペースから下スペース、上スペースから]は制限されます。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let identifier = "reusedCell"
var cell = tableView.dequeueReusableCell(withIdentifier: identifier)
if(cell == nil) {
cell = UITableViewCell(style: UITableViewCellStyle.subtitle, reuseIdentifier: identifier)
}
let image = UIImage(named: "TableView\(indexPath.row)")
let imageView = UIImageView(image: image)
cell?.addSubview(imageView)
imageView.contentMode = UIViewContentMode.scaleAspectFill
imageView.clipsToBounds = true
return cell!
}
画像が正しく4.7にサイズ設定されており、5.5インチのiPhoneの画面ではなく、iphone 5、5SとSEで:
これは私がテーブルビューのcellForRowAtにUIImageViewを使用する方法です。
ご迷惑をおかけして申し訳ありません。あなたがimageView
の制約を加える必要があり おかげ