###前提・実現したいこと
-----先ほど質問させていただいた内容の次の段階になります。-----
★ 画像を指定しても綺麗にCellが表示された上でその下に画像を表示したい
TableViewの一番下にくっついて来るImageViewを実装したい。
くっついてくる画像サイズは縦横ともに画面サイズ
※イメージとしてはセルが最後まで来るとImageViewが現れ最終的にImageViewのみ表示される。
※下にスワイプすると再びセルが表示される。
###発生している問題・エラーメッセージ
・左が画像を指定した場合(テスト用に緑色の画像)
・右がtableFooterView
に指定している大きさ(青色はわかりやすいようにbackgroundcolor
)
###該当のソースコード
Swift
1import UIKit 2 3class ViewController: UIViewController, UITableViewDataSource { 4 5 @IBOutlet weak var myTableView: UITableView! 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 let window = UIScreen.mainScreen().bounds.size 10 let myImage = UIImageView(frame: CGRectMake(0, 0, window.width, 200)) 11 myImage.contentMode = .ScaleAspectFill 12 myImage.image = UIImage(named: "Green_Image") 13 myImage.backgroundColor = UIColor.blueColor() 14 myTableView.tableFooterView = myImage 15 } 16 17 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 18 return 30 19 } 20 21 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 22 let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) 23 let label = cell.viewWithTag(1) as! UILabel 24 label.text = "\(indexPath.row)" 25 return cell 26 } 27 28}
###試したこと
画像サイズを小さくしてみると綺麗に収まってくれます。
###補足情報(言語/FW/ツール等のバージョンなど)
・Xcode7.3.1
・Swift2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/08/04 10:38 編集
2016/08/05 01:14