質問編集履歴
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,3 +27,58 @@
|
|
27
27
|
}
|
28
28
|
}
|
29
29
|
```
|
30
|
+
|
31
|
+
分かり辛くて申し訳ありません。
|
32
|
+
全部のコード若干変わりますが下記に載せます。
|
33
|
+
sheet(SecondView)を開いて閉じる動作を期待していますが、できない状況です。
|
34
|
+
|
35
|
+
追加コード
|
36
|
+
```swift
|
37
|
+
|
38
|
+
//ContentView
|
39
|
+
import SwiftUI
|
40
|
+
|
41
|
+
struct ContentView: View {
|
42
|
+
@ObservedObject var test:testClass = testClass()
|
43
|
+
var body: some View {
|
44
|
+
VStack {
|
45
|
+
Button(action:{
|
46
|
+
test.def.toggle()
|
47
|
+
}){
|
48
|
+
Text("クリック")
|
49
|
+
}
|
50
|
+
.sheet(isPresented: $test.def){
|
51
|
+
SecondView()
|
52
|
+
}
|
53
|
+
}
|
54
|
+
.padding()
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
class testClass: ObservableObject{
|
59
|
+
@Published var def:Bool = false
|
60
|
+
}
|
61
|
+
|
62
|
+
struct ContentView_Previews: PreviewProvider {
|
63
|
+
static var previews: some View {
|
64
|
+
ContentView()
|
65
|
+
}
|
66
|
+
}
|
67
|
+
```
|
68
|
+
```swift
|
69
|
+
//SecondView
|
70
|
+
import SwiftUI
|
71
|
+
|
72
|
+
struct SecondView: View {
|
73
|
+
@ObservedObject var def = testClass()
|
74
|
+
var body: some View {
|
75
|
+
Button(action:{
|
76
|
+
def.def = false
|
77
|
+
}){
|
78
|
+
VStack{
|
79
|
+
Text("閉じる")
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
```
|
1
誤字脱字変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
SwiftUIView上でsheetの開閉を行いたいのですが、できません。
|
2
|
-
アプリ立ち上げ時、sheetが開いてtestview内クラス実行時sheetが閉じる動作
|
2
|
+
アプリ立ち上げ時、sheetが開いてtestview内クラス実行時sheetが閉じる動作を想定しています。
|
3
3
|
|
4
4
|
アプリ立ち上げ時sheetは立ち上がってきますが、isShowingをfalseにしてもsheetが消えません。
|
5
5
|
|