###前提・実現したいこと
TableViewの一番下にくっついて来るImageViewを実装したい。
くっついてくる画像サイズは縦横ともに画面サイズ
※イメージとしてはセルが最後まで来るとImageViewが現れ最終的にImageViewのみ表示される。
※下にスワイプすると再びセルが表示される。
###発生している問題・エラーメッセージ
・真ん中に大きく表示されてしまう。
・セルが下に隠れてしまう。
-----そもそもFooterの認識が違うかもしれないです。。。-----
###該当のソースコード
Swift
1import UIKit 2 3class ViewController: UIViewController, UITableViewDataSource { 4 5 override func viewDidLoad() { 6 super.viewDidLoad() 7 // Do any additional setup after loading the view, typically from a nib. 8 } 9 10 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 11 return 10 12 } 13 14 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 15 let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) 16 let label = cell.viewWithTag(1) as! UILabel 17 return cell 18 } 19 20 func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView { 21 let window = UIScreen.mainScreen().bounds.size 22 let myImage = UIImageView(frame: CGRectMake(0, 0, window.width, window.height)) 23 myImage.contentMode = .ScaleAspectFit 24 myImage.image = UIImage(named: "back") 25 26 return myImage 27 } 28 29 func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { 30 let window = UIScreen.mainScreen().bounds.size 31 return window.height 32 } 33 34}
###試したこと
viewForFooterInsection
に画像を指定するだけだと、
高さが足りないため、heightForFooterInSection
に画像の高さを指定してみた。
###補足情報(言語/FW/ツール等のバージョンなど)
・Xcode7.3.1
・Swift2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。