teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

追記

2020/04/10 13:37

投稿

yasumaro
yasumaro

スコア67

title CHANGED
File without changes
body CHANGED
@@ -4,4 +4,61 @@
4
4
  また消えてしまう原因が知りたいです。
5
5
  戻り方は
6
6
  画面下にスワイプして戻っています。
7
- 今後はListでユーザーを表示して行(cell)をタップしたらonDissmissで画面を閉じるつもりでいます。
7
+ 今後はListでユーザーを表示して行(cell)をタップしたらonDissmissで画面を閉じるつもりでいます。
8
+
9
+
10
+ 画像を表示している画面のコードです。
11
+ navigationItemのボタンを押すと.sheetのispresentedをtrueにして次の画面を表示させています。
12
+ このボタンを押した瞬間に画像が消えてplaceholderの画像になってしまいます
13
+ ```ここに言語を入力
14
+
15
+
16
+ import SwiftUI
17
+
18
+ struct HogeListView: View {
19
+
20
+ @ObservedObject var hogeVM = HogewModel()
21
+ @State var nextView = false
22
+
23
+ var body: some View {
24
+ NavigationView {
25
+ List(hogeVM.hogeLists){ hogeList in
26
+
27
+ VStack{
28
+
29
+ HStack{
30
+
31
+ URLImage(url: hogeList.user!.profileImageURL) {
32
+ $0.renderingMode(.original)
33
+ .resizable()
34
+ .scaledToFit()
35
+ .clipShape(Circle())
36
+ .frame(width: 50.0, height: 50.0)
37
+ .overlay(Circle().stroke(Color.white,lineWidth:4).shadow(radius: 10))
38
+ }
39
+ Text(hogeList.user.username)
40
+ Text(hoge.messageText)
41
+
42
+ }
43
+ }
44
+ //}
45
+ }
46
+
47
+ .navigationBarTitle("タイトル",displayMode: .inline)
48
+ .navigationBarItems(trailing: Button(action: {
49
+ self.nextView.toggle()
50
+ }) {
51
+ Text("+")
52
+ .sheet(isPresented: $nextView, content:{NextViewList(nextView: self.$nextView)})
53
+
54
+
55
+ })
56
+
57
+
58
+ }
59
+
60
+ }
61
+ }
62
+
63
+
64
+ ```

2

修正

2020/04/10 13:37

投稿

yasumaro
yasumaro

スコア67

title CHANGED
@@ -1,1 +1,1 @@
1
- swiftUI,ページを戻ると画像が消えてしまう問題
1
+ swiftUI,ページを戻ると画像が消えてしまう
body CHANGED
File without changes

1

追記

2020/04/10 13:06

投稿

yasumaro
yasumaro

スコア67

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,7 @@
1
1
  画像を取得したページから.sheet(isPresent)で別の画像をだしてから戻ると画像が消えてしまいます。
2
2
  ソースは[こちら](https://masamichi.me/development/2019/10/12/swiftui-url-image.html)のを参考にしています。(ほぼ同じです)
3
3
  どのようにしたら画像を表示したままにできるでしょうか。
4
- また消えてしまう原因が知りたいです。
4
+ また消えてしまう原因が知りたいです。
5
+ 戻り方は
6
+ 画面下にスワイプして戻っています。
7
+ 今後はListでユーザーを表示して行(cell)をタップしたらonDissmissで画面を閉じるつもりでいます。