元のドキュメント: developer.apple.com/documentation/swiftui/view/accessibilityrotor(_:entries:entryid:entrylabel:)-4qsb1


インスタンスメソッド


accessibilityRotor(_:entries:entryID:entry
Label:)


指定されたユーザー可視ラベルとエントリを使用して、アクセシビリティローターを作成します。


iOS 15.0+ iPadOS 15.0+ Mac Catalyst 15.0+ macOS 12.0+

tvOS 15.0+ visionOS 1.0+ watchOS 8.0+

nonisolated
func
accessibilityRotor<EntryModel, ID>(
_ rotorLabel: Text,
entries: [EntryModel],
entryID: KeyPath<EntryModel, ID>,
entryLabel: KeyPath<EntryModel, String>
) -> some View where ID : Hashable

nonisolated
func
accessibilityRotor<EntryModel, ID>(
_ rotorLabelKey: LocalizedStringKey,
entries: [EntryModel],
entryID: KeyPath<EntryModel, ID>,
entryLabel: KeyPath<EntryModel, String>
) -> some View where ID : Hashable

nonisolated
func
accessibilityRotor<EntryModel, ID>(
_ rotorLabelResource: LocalizedStringResource,
entries: [EntryModel],
entryID: KeyPath<EntryModel, ID>,
entryLabel: KeyPath<EntryModel, String>
) -> some View where ID : Hashable

nonisolated
func
accessibilityRotor<EntryModel, ID>(
_ systemRotor: AccessibilitySystemRotor,
entries: [EntryModel],
entryID: KeyPath<EntryModel, ID>,
entryLabel: KeyPath<EntryModel, String>
) -> some View where ID : Hashable

nonisolated
func
accessibilityRotor<L, EntryModel, ID>(
_ rotorLabel: L,
entries: [EntryModel],
entryID: KeyPath<EntryModel, ID>,
entryLabel: KeyPath<EntryModel, String>
) -> some View where L : StringProtocol, ID : Hashable




パラメータ


rotorLabel

ユーザーに対してこのローターを識別するためのローカライズされたラベル。


entries

ローターのエントリを生成するために使用される値の配列。


entryID

エントリタイプのキーパス。このパスを使用してエントリの識別子を生成します。生成された識別子は、ForEach 内の識別子、または ScrollView 内の明示的な id 呼び出しと一致しなければなりません。


entryLabel

エントリタイプのキーパス。これを使用して、各ローターエントリにユーザー可視ラベルを取得できます。これは、macOS でユーザーがローターのエントリリストを開いたときに使用されます。



議論


アクセシビリティローターは、アクセシビリティ機能を利用するユーザーがユーザーインターフェースの特定の要素、あるいはその要素内の特定のテキスト範囲に素早く移動するためのショートカットです。


この修飾子を使用するには、ローターを ScrollView に付属させるか、ScrollView 内に直接アクセシビリティ要素(ForEach など)を配置する必要があります。ユーザーがこのローターからエントリに移動すると、SwiftUI は必要に応じて自動的にスクロールして表示します。


以下の例では、メッセージアプリケーションがローターを作成し、ユーザーがメッセージの縦方向のスタック内の見出しに移動できるようにします。


// `messages` is a list of `Message`s that have a `subject` and a
// `uuid`. `vipMessages` is a filtered version of that list
// containing only messages from VIPs.
ScrollView {
    LazyVStack {
          ForEach(messageListItems) { messageListItem in
              switch messageListItem {
                  case .heading(let subject):
                      Text(subject)
                  case .message(let message):
                      MessageView(message)
              }
          }
      }
  }
.accessibilityElement(children: .contain)
  .accessibilityRotor("VIPs", entries: vipMessages,
      id: \.uuid, label: \.subject)
  )




以下も見よ


ローターを使った作業


func accessibilityRotor(_:entries:)

指定されたユーザー可視ラベルと、コンテンツクロージャから生成されたエントリを使用して、アクセシビリティローターを作成します。


func accessibilityRotor(_:entries:entryLabel:)

指定されたユーザー可視ラベルとエントリを使用して、アクセシビリティローターを作成します。


func accessibilityRotor(_:textRanges:)

指定されたユーザー可視ラベルと、指定された各範囲のエントリを持つアクセシビリティローターを作成します。ローターは現在のアクセシビリティ要素に付属され、各エントリはその要素の指定された範囲に配置されます。














トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ












トップへ