現在storyboardを使いStaticCellsでTableViewを作っています。
StaticCellsではセルの追加や削除などができないということは調べてわかりました。(セルの数が変わる)
では高さの変更をすることはできないのでしょうか?
ちなみに下記のoverride funcではstoryboardの設定から高さを変更することができました。(変更ではなくこの値でTableを作っている?)
override func tableView(tableView: UITableView,heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat{ return 30 }
このようなfunctionを作りアプリを操作している時にボタンやスイッチで高さを変えられないのでしょうか
似たような感じで下記のfunctionを作ってみましたが、関数の中には入ってはいるようですがCellの高さは変わりませんでした
func heightChanger(tableView: UITableView,heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat{ print("関数") print(indexPath.row) if indexPath.section == 2 && indexPath.row >= 3 { print("if文内") return 30 } return 0 }
調べてみてもStatic Cellsを使っている例が少なくなかなか参考になるものが見つかりませんでした。
またもし高さ変更ができないのであればできないと回答が欲しいです。
宜しくお願いします。
追加のコード
import UIKit class ViewController: UITableViewController{ @IBOutlet var table: UITableView! var height: CGFloat = 0.0 var num = 0 override func viewDidLoad() { super.viewDidLoad() } override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { if num == 0{ if indexPath.section == 0 && indexPath.row == 4 { num += 1 return 0 } if indexPath.section == 0 && indexPath.row >= 1 { return 0 } else { if indexPath.section == 0 && indexPath.row == num { return 50 } } } if indexPath.section == 0 && indexPath.row >= num{ return 0 } return 50 } @IBAction func pushButton(sender: AnyObject) { num += 1 heightChanger() } func heightChanger() { if num <= 3{ table.reloadRowsAtIndexPaths([NSIndexPath(forRow: 0, inSection: num)], withRowAnimation: .Automatic) } else{ print(12345) } } }

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/09/06 07:05
2016/09/06 07:20
2016/09/06 07:27
2016/09/06 07:59
2016/09/07 03:54
2016/09/07 04:24 編集
2016/09/07 07:22