スクロールビューには多くのコンポーネントが含まれたコンテンツビューがあり、コンポーネントはクリック中にアニメートされます。 1つの問題があります、コンテンツビューはサイズを適切に変更しません。どの人がこれを修正するか考えていますか?それに続くcontnentビューのサイズをスクロールしながら。ここに記述したコードは、その私がやっている:コンテンツビュー親スクロールビューへのサイズ変更
func updateDropDownList(tableView: UITableView, height: CGFloat, state: CGFloat) {
let rowHeight = tableView.rowHeight
UIView.animate(withDuration: 0.3, animations: {
var frame = CGRect(x: tableView.frame.origin.x, y: tableView.frame.origin.y, width: tableView.frame.width, height: height)
tableView.frame = frame
if state == -1 {
frame = CGRect(x: tableView.frame.origin.x, y: tableView.frame.origin.y, width: tableView.frame.width, height: CGFloat(tableView.numberOfRows(inSection: 0)) * rowHeight)
}
self.updatePositions(tableView: tableView, frame: frame, state: state, rowHeight: rowHeight)
})
}
状態:
- 状態= 1つの//テーブルビューのサイズを変更
- 状態= -1 //バックoryginalサイズへ
そして、私は、各コンポーネントの位置を変更することができます方法:
func updatePositions(tableView: UITableView, frame: CGRect, state: CGFloat, rowHeight: CGFloat) {
switch tableView {
case facilitiesTableView:
statusLabel.frame.origin.y += state * (frame.height - rowHeight)
statusTableView.frame.origin.y += state * (frame.height - rowHeight)
serviceTableView.frame.origin.y += state * (frame.height - rowHeight)
vehiclesCollection.frame.origin.y += state * (frame.height - rowHeight)
colorsCollection.frame.origin.y += state * (frame.height - rowHeight)
scrollView.contentSize.height += state * colorsCollection.frame.height
// contentView.frame.size = CGSize(width: contentView.frame.size.width, height: scrollView.contentSize.height)
case statusTableView:
serviceTableView.frame.origin.y += state * (frame.height - rowHeight)
vehiclesCollection.frame.origin.y += state * (frame.height - rowHeight)
colorsCollection.frame.origin.y += state * (frame.height - rowHeight)
scrollView.contentSize.height += state * colorsCollection.frame.height
case serviceTableView:
vehiclesCollection.frame.origin.y += state * (frame.height - rowHeight)
colorsCollection.frame.origin.y += state * (frame.height - rowHeight)
scrollView.contentSize.height += state * colorsCollection.frame.height
default:
break
}
}
コンテンツビューのサイズを変更するコメントが1行ありますが、これを呼び出すと画面が乱れてしまいますが、クリックしたテーブルのサイズが変更されません。
スクロールビューに合うようにリサイズされたコンセントのビューがありません。最も低いコンポーネントをクリックできません。コンテンツビューの範囲外です。
ありがとうございます!
私はアニメーションの前にそれを追加すると助けにならないでしょうし、それを置いてもテーブルビューでもクリックすることはできません - それは伸びません – yerpy
あなたはどんなレイアウト制約を使っていますか? –
私は午前中です。スクロール表示の上端、下端、先頭と末尾のように、それぞれが0で、スクロール表示のスーパービューでは、高さと幅が同じです。 – yerpy