2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[SwiftUI]見た目を変えると挙動が変わってしまう例

2
Posted at

SwiftUIでは見た目を変えるだけで、挙動が変わる場合がある。
例えば次のような構造の場合、横にボタンが2つ並んでいる。

HStack {
  Button({
  }) {
    Text("button A")
  }

  Button({
  }) {
    Text("button B")
  }
}

これをテーブル表示するために、Listで括る

List {
  HStack {
    Button({
    }) {
      Text("button A")
    }
    
    Button({
    }) {
      Text("button B")
    }
  }
}

すると、HStack内のボタンのタップは無視されてセルのタップで両方のボタンが反応するようになる。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?