Skip to content

非公式本サイトは非公式の日本語ドキュメントであり、Cloudflare 公式サイトではありません。最新情報はdevelopers.cloudflare.comをご確認ください。

GridView

最終更新 Markdown で表示Agent セットアップ

子ビューをレスポンシブなグリッドに配置する汎用グリッドレイアウトビューです。 縦向きと横向きの両方に対応し、表示するアイテム数の上限を設定できます。

イニシャライザーのパラメーター

パラメーター 必須 デフォルト 説明
maxItems UInt 9 グリッドに表示できるアイテムの最大数
showingCurrently UInt - 現在グリッドに表示しているアイテム数
getChildView @escaping () -> CellContainerView - 各グリッドセル用の子ビューを生成するクロージャ

メソッド

メソッド 戻り値の型 説明
settingFrames(visibleItemCount:animation:completion:) Void 任意でアニメーションを付けて、縦向きで子ビューをレイアウトします
settingFramesForLandScape(visibleItemCount:animation:completion:) Void 任意でアニメーションを付けて、横向きで子ビューをレイアウトします
childView(index:) CellContainerView? 指定したインデックスの子ビューを返します
prepareForReuse(childView:) Void 子ビューを再利用できるように準備します

使用例

基本的な使い方

import RealtimeKitUI

let gridView = GridView(
    maxItems: 6,
    showingCurrently: 4,
    getChildView: {
        return CellContainerView()
    }
)
view.addSubview(gridView)

レイアウトを更新する場合

import RealtimeKitUI

let gridView = GridView(
    maxItems: 9,
    showingCurrently: 3,
    getChildView: {
        return CellContainerView()
    }
)
view.addSubview(gridView)

// Update layout with animation
gridView.settingFrames(
    visibleItemCount: 4,
    animation: true,
    completion: {
        print("Layout updated")
    }
)

役に立ちましたか?