č³Ŗå•ć‚’ć™ć‚‹ć“ćØć§ć—ć‹å¾—ć‚‰ć‚ŒćŖć„ć€å›žē­”ć‚„ć‚¢ćƒ‰ćƒć‚¤ć‚¹ćŒć‚ć‚‹ć€‚

15分čŖæć¹ć¦ć‚‚ć‚ć‹ć‚‰ćŖ恄恓ćØćÆ态č³Ŗå•ć—ć‚ˆć†ļ¼

ę–°č¦ē™»éŒ²ć—恦č³Ŗå•ć—ć¦ćæ悈恆
ćŸć ć„ć¾å›žē­”ēŽ‡
86.02%
Xcode

XcodećÆć‚½ćƒ•ćƒˆć‚¦ć‚§ć‚¢é–‹ē™ŗć®ćŸć‚ć®ć€Apple恮ēµ±åˆé–‹ē™ŗē’°å¢ƒć§ć™ć€‚Mac OSXć«ä»˜éšć™ć‚‹ć‹ćŸć”ć§é…åøƒć•ć‚Œć¦ć„ć¾ć™ć€‚

Swift

SwiftćÆć€ć‚¢ćƒƒćƒ—ćƒ«ć®iOSćŠć‚ˆć³OS Xć®ćŸć‚ć®ćƒ—ćƒ­ć‚°ćƒ©ćƒŸćƒ³ć‚°č؀čŖžć§ć€Objective-C悄Objective-C++ćØå…±å­˜ć™ć‚‹ć“ćØćŒę„å›³ć•ć‚Œć¦ć„ć¾ć™

Q&A

受付äø­

šŸŽć€SwiftUI怑ćƒŖć‚¹ćƒˆ(NavigationLink)恫悂恐悋恐悋ćØå›žć‚‹ć‚¤ćƒ³ć‚øć‚²ćƒ¼ć‚æćƒ¼ć‚’č”Øē¤ŗ恕恛恟恄šŸŽ

SA-KYO
SA-KYO

ē·åˆć‚¹ć‚³ć‚¢34

Xcode

XcodećÆć‚½ćƒ•ćƒˆć‚¦ć‚§ć‚¢é–‹ē™ŗć®ćŸć‚ć®ć€Apple恮ēµ±åˆé–‹ē™ŗē’°å¢ƒć§ć™ć€‚Mac OSXć«ä»˜éšć™ć‚‹ć‹ćŸć”ć§é…åøƒć•ć‚Œć¦ć„ć¾ć™ć€‚

Swift

SwiftćÆć€ć‚¢ćƒƒćƒ—ćƒ«ć®iOSćŠć‚ˆć³OS Xć®ćŸć‚ć®ćƒ—ćƒ­ć‚°ćƒ©ćƒŸćƒ³ć‚°č؀čŖžć§ć€Objective-C悄Objective-C++ćØå…±å­˜ć™ć‚‹ć“ćØćŒę„å›³ć•ć‚Œć¦ć„ć¾ć™

1回ē­”

0悰惃惉

0ć‚ÆćƒŖ惃惗

436é–²č¦§

ꊕēØæ2023/01/06 04:16

å‰ę

List { ForEach(self.threads, id: \.objectId) { thread in NavigationLink(destination: ThreadView(thread: thread)) { ThreadListRow(thread: thread) }

č”Øē¤ŗć•ć‚Œć¦ć„ć‚‹ćƒŖć‚¹ćƒˆć‚’ć‚ÆćƒŖ惃ć‚Æ恙悋ćØ
恐悋恐悋ćØå›žć‚‹ć‚¤ćƒ³ć‚øć‚²ćƒ¼ć‚æćƒ¼ć‚’č”Øē¤ŗć•ć›ćŸć„ć®ć§ć™ćŒć€
č”Øē¤ŗć•ć‚Œć¦ć„ć‚‹ćƒŖć‚¹ćƒˆć‚’ć‚ÆćƒŖ惃ć‚Æ恙悋ćØ
å‹•ä½œć‚‚é‡ćć€ć‚¤ćƒ³ć‚øć‚²ćƒ¼ć‚æćƒ¼ć‚‚č”Øē¤ŗć•ć‚Œć¾ć›ć‚“ć€‚

実ē¾ć—ćŸć„ć“ćØ

č”Øē¤ŗć•ć‚Œć¦ć„ć‚‹ćƒŖć‚¹ćƒˆć‚’ć‚ÆćƒŖ惃ć‚Æ恙悋ćØ态
ē”»é¢é·ē§»ć®éš›ć€
ć‚¤ćƒ³ć‚øć‚²ćƒ¼ć‚æćƒ¼ć‚’č”Øē¤ŗ恕恛恟恄怂

č©²å½“ć®ć‚½ćƒ¼ć‚¹ć‚³ćƒ¼ćƒ‰

Swift

1// 2// ThreadListView.swift 3// forum 4// 5// Created by Atsushi on 2021/08/06. 6// 7 8import SwiftUI 9import NCMB 10 11struct ThreadListView: View { 12 @State private var threads: [NCMBObject] = [] 13 @State private var showModal = false 14 @State private var showAlert = false 15 @State var isPresentedProgressView = false 16 var body: some View { 17 NavigationView { 18 List { 19 ForEach(self.threads, id: \.objectId) { thread in 20 NavigationLink(destination: ThreadView(thread: thread)) { 21 ThreadListRow(thread: thread) 22 } 23 } 24 .onDelete(perform: delete) 25 } 26 .navigationBarTitle("ęŽ²ē¤ŗęæ", displayMode: .inline) 27 .toolbar { 28 ToolbarItem(placement: .navigationBarTrailing) { 29 Button { 30 showModal.toggle() 31 } label: { 32 Image(systemName: "plus") 33 .resizable() 34 .padding(6) 35 .frame(width: 24, height: 24) 36 .foregroundColor(.blue) 37 } 38 } 39 } 40 } 41 .onAppear { 42 DispatchQueue.main.asyncAfter(deadline: .now()+0.3) { 43 getThread() 44 } 45 } 46 .sheet(isPresented: $showModal) { 47 AddThreadView() 48 } 49 .onChange(of: showModal, perform: { _ in 50 if !showModal { 51 getThread() 52 } 53 }) 54 .alert(isPresented: $showAlert, content: { 55 Alert(title: Text("å‰Šé™¤ć«å¤±ę•—ć—ć¾ć—ćŸć€‚ęØ©é™ćŒćŖ恄悈恆恧恙怂")) 56 }) 57 } 58 59 private func manageProgress() { 60 // ProgressView č”Øē¤ŗ 61 isPresentedProgressView = true 62 // 3ē§’å¾Œć«éžč”Øē¤ŗ恫 63 DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) { 64 self.isPresentedProgressView = false 65 } 66 } 67 68 private func getThread() { 69 let query = NCMBQuery.getQuery(className: "Thread") 70 let results = query.find() 71 switch results { 72 case let .success(ary): 73 threads = ary 74 case .failure(_): break 75 } 76 } 77 78 private func delete(at offsets: IndexSet) { 79 let thread = self.threads[Array(offsets)[0]] as NCMBObject 80 let results = thread.delete() 81 switch results { 82 case .success(_): 83 getThread() 84 case .failure(_): 85 showAlert = true 86 } 87 } 88} 89

č©¦ć—ćŸć“ćØ

Swift

1NavigationView { 2 List { 3 ForEach(self.threads, id: \.objectId) { thread in 4 NavigationLink(destination: ThreadView(thread: thread)) { 5 ThreadListRow(thread: thread) 6 } 7 }

恮äø‹ć«ć€

Swift

1;if isPresentedProgressView { 2 Color.gray.opacity(0.5) 3 ProgressView("čŖ­ćæč¾¼ćæäø­") 4 }

悒

Swift

1NavigationView { 2 List { 3 ForEach(self.threads, id: \.objectId) { thread in 4 NavigationLink(destination: ThreadView(thread: thread)) { 5 ThreadListRow(thread: thread) 6 };if isPresentedProgressView { 7 Color.gray.opacity(0.5) 8 ProgressView("čŖ­ćæč¾¼ćæäø­") 9 } 10 } 11

ć®ć‚ˆć†ć«čؘčæ°ć—ćŸć®ć§ć™ćŒć€
ProgressView("čŖ­ćæč¾¼ćæäø­")ćÆč”Øē¤ŗć•ć‚Œć¾ć›ć‚“ć€‚

č£œč¶³ęƒ…å ±ļ¼ˆFW/ćƒ„ćƒ¼ćƒ«ć®ćƒćƒ¼ć‚øćƒ§ćƒ³ćŖ恩ļ¼‰

é‡ć­ć¦ć®č³Ŗå•ć§
大変ē”³ć—čسćŖć„ć®ć§ć™ćŒ
ć“ć”ć‚‰ć‚‚ä»„å‰ć®č³Ŗå•åŒę§˜ć€åŒć˜ę–¹ę³•ć§č§£ę±ŗ恧恍悋ćØę€ć£ć¦ć„ć¾ć—ćŸćŒć€
č§£ę±ŗć§ćć¾ć›ć‚“ć§ć—ćŸć€‚ć€‚ć€‚

何åŗ¦ć‚‚ē”³ć—čØ³ć‚ć‚Šć¾ć›ć‚“ćŒć€
ćƒ’ćƒ³ćƒˆć‚„ć‚¢ćƒ‰ćƒć‚¤ć‚¹ć„ćŸć ć‘ć¾ć™ćØå¤§å¤‰å¬‰ć—ć„ć§ć™ć€‚

ć‚ˆć‚ć—ććŠé”˜ć„ć—ć¾ć™ć€‚

갗恫ćŖ悋č³Ŗå•ć‚’ć‚ÆćƒŖ惃惗恙悋

ć‚ÆćƒŖ惃惗恗恟č³Ŗ問ćÆć€å¾Œć‹ć‚‰ć„ć¤ć§ć‚‚ćƒžć‚¤ćƒšćƒ¼ć‚ø恧ē¢ŗčŖć§ćć¾ć™ć€‚

ć¾ćŸć‚ÆćƒŖ惃惗恗恟č³Ŗå•ć«å›žē­”ćŒć‚ć£ćŸéš›ć€é€šēŸ„ć‚„ćƒ”ćƒ¼ćƒ«ć‚’å—ć‘å–ć‚‹ć“ćØćŒć§ćć¾ć™ć€‚

äø‹čØ˜ć®ć‚ˆć†ćŖč³Ŗ問ćÆęŽØå„Øć•ć‚Œć¦ć„ć¾ć›ć‚“ć€‚

  • č³Ŗå•ć«ćŖć£ć¦ć„ćŖ恄ꊕēØæ
  • ć‚¹ćƒ‘ćƒ ć‚„ę”»ę’ƒēš„ćŖč”Øē¾ć‚’ē”Ø恄恟ꊕēØæ

適切ćŖč³Ŗå•ć«äæ®ę­£ć‚’ä¾é ¼ć—ć¾ć—ć‚‡ć†ć€‚

1T2R3M4

2023/01/06 04:37

šŸŽćÆć©ć®ć‚ˆć†ćŖę„å‘³ćŒć‚ć‚‹ć®ć§ć—ć‚‡ć†ć‹ć€‚ ē‰¹ę®ŠćŖSwiftUI恧恗悇恆恋怂
SA-KYO

2023/01/06 04:48

恙ćæć¾ć›ć‚“ć€ć€ć€ SwiftćŖ恮恧Appleć®ć‚Šć‚“ć”ćƒžćƒ¼ć‚Æ恌 恂悋ćØåˆ†ć‹ć‚Šć‚„ć™ć„ć‹ćØ态态

回ē­”1件

0

manageProgress() ćƒ”ć‚½ćƒƒćƒ‰ćŒå®Ÿč”Œć•ć‚Œć¦ć„ćŖ恄恟悁
ć‚¤ćƒ³ć‚øć‚±ćƒ¼ć‚æćƒ¼ćŒčµ·å‹•ć—ć¦ć„ćŖ恄ćØęŽØęø¬ć—ć¾ć™ć€‚

ć¾ćŸć€
NavigationStack ć®å¤–ć« ProgressView() 悒å‡ŗć™ę–¹é‡ć§
ēµ„悓恧ćæ恦ćÆå¦‚ä½•ć§ć—ć‚‡ć†ć‹ļ¼Ÿ

NavigationStack ć®å¤–ć®č¦ē“ ćÆ
遷ē§»å…ˆć§ć‚‚ę®‹ć‚Šć¾ć™ć€‚

Swift

1import SwiftUI 2 3struct ContentView: View { 4 @State var isPresentedProgressView = false 5 @State var isActive = false 6 var body: some View { 7 ZStack{ 8 NavigationStack { 9 VStack { 10 Button(action: manageProgress){ Text("č”Øē¤ŗ/非č”Øē¤ŗåˆ‡ć‚Šę›æ恈")} 11 NavigationLink(destination: Text("aaa"), isActive: $isActive) { 12 13 } 14 ZStack { 15 Text("Hello, world!") .padding() 16 17 } 18 } 19 } 20 if isPresentedProgressView { 21 Color.gray.opacity(0.5) 22 ProgressView() 23 } 24 } 25 } 26 private func manageProgress() { 27 // ProgressView č”Øē¤ŗ 28 isPresentedProgressView = true 29 DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) { 30 isActive = true 31 } 32 DispatchQueue.main.asyncAfter(deadline: .now() + 6.0) { 33 isPresentedProgressView = false 34 } 35 } 36}

å‹•ćć‹åˆ†ć‹ć‚Šć¾ć›ć‚“ćŒ
ę¬”ć®ć‚ˆć†ćŖå†…å®¹ć§ć™ć€‚

Swift

1import SwiftUI 2import NCMB 3 4struct ThreadListView: View { 5 @State private var threads: [NCMBObject] = [] 6 @State private var showModal = false 7 @State private var showAlert = false 8 @State var isPresentedProgressView = false 9 @State var isNavigationLinkActive: [Bool] = [] 10 var body: some View { 11 ZStack{ 12 NavigationView { 13 List { 14 ForEach(0 ..< threads.count, id: \.self) { i in 15 ZStack { 16 Button(action: manageProgress(i)){} 17 NavigationLink(destination: ThreadView(thread: threads[i]), isActive: $isNavigationLinkActive[i]) { 18 ThreadListRow(thread: thread) 19 } 20 } 21 } 22 .onDelete(perform: delete) 23 } 24 .navigationBarTitle("ęŽ²ē¤ŗęæ", displayMode: .inline) 25 .toolbar { 26 ToolbarItem(placement: .navigationBarTrailing) { 27 Button { 28 showModal.toggle() 29 } label: { 30 Image(systemName: "plus") 31 .resizable() 32 .padding(6) 33 .frame(width: 24, height: 24) 34 .foregroundColor(.blue) 35 } 36 } 37 } 38 } 39 .onAppear { 40 DispatchQueue.main.asyncAfter(deadline: .now()+0.3) { 41 getThread() 42 ForEach(self.threads, id: \.objectId) { thread in 43 isNavigationLinkActive.append(false) 44 } 45 } 46 47 } 48 .sheet(isPresented: $showModal) { 49 AddThreadView() 50 } 51 .onChange(of: showModal, perform: { _ in 52 if !showModal { 53 getThread() 54 ForEach(self.threads, id: \.objectId) { thread in 55 isNavigationLinkActive.append(false) 56 } 57 } 58 }) 59 .alert(isPresented: $showAlert, content: { 60 Alert(title: Text("å‰Šé™¤ć«å¤±ę•—ć—ć¾ć—ćŸć€‚ęØ©é™ćŒćŖ恄悈恆恧恙怂")) 61 }) 62 if isPresentedProgressView { 63 Color.gray.opacity(0.5) 64 ProgressView("čŖ­ćæč¾¼ćæäø­") 65 } 66 } 67 } 68 69 private func manageProgress(_ index: Int) { 70 // ProgressView č”Øē¤ŗ 71 isPresentedProgressView = true 72 isNavigationLinkActive[index] = true 73 // 3ē§’å¾Œć«éžč”Øē¤ŗ恫 74 DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) { 75 self.isPresentedProgressView = false 76 } 77 } 78 79 private func getThread() { 80 let query = NCMBQuery.getQuery(className: "Thread") 81 let results = query.find() 82 switch results { 83 case let .success(ary): 84 threads = ary 85 case .failure(_): break 86 } 87 } 88 89 private func delete(at offsets: IndexSet) { 90 let thread = self.threads[Array(offsets)[0]] as NCMBObject 91 let results = thread.delete() 92 switch results { 93 case .success(_): 94 getThread() 95 case .failure(_): 96 showAlert = true 97 } 98 } 99}

ꊕēØæ2023/01/07 01:52

ē·Ø集2023/01/07 02:54
uni2

ē·åˆć‚¹ć‚³ć‚¢177

äø‹čØ˜ć®ć‚ˆć†ćŖ回ē­”ćÆęŽØå„Øć•ć‚Œć¦ć„ć¾ć›ć‚“ć€‚

  • č³Ŗå•ć®å›žē­”恫ćŖć£ć¦ć„ćŖ恄ꊕēØæ
  • ć‚¹ćƒ‘ćƒ ć‚„ę”»ę’ƒēš„ćŖč”Øē¾ć‚’ē”Ø恄恟ꊕēØæ

ć“ć®ć‚ˆć†ćŖ回ē­”恫ćÆäæ®ę­£ć‚’ä¾é ¼ć—ć¾ć—ć‚‡ć†ć€‚

ć¾ć ćƒ™ć‚¹ćƒˆć‚¢ćƒ³ć‚µćƒ¼ćŒéøć°ć‚Œć¦ć„ć¾ć›ć‚“

会哔ē™»éŒ²ć—ć¦å›žē­”恗恦ćæ悈恆

ć‚¢ć‚«ć‚¦ćƒ³ćƒˆć‚’ćŠęŒć”ć®ę–¹ćÆ

15分čŖæć¹ć¦ć‚‚ć‚ć‹ć‚‰ćŖ恄恓ćØćÆ
teratail恧č³Ŗå•ć—ć‚ˆć†ļ¼

ćŸć ć„ć¾ć®å›žē­”ēŽ‡
86.02%

č³Ŗå•ć‚’ć¾ćØ悁悋恓ćØ恧
ę€č€ƒć‚’ę•“ē†ć—恦ē“ ę—©ćč§£ę±ŗ

ćƒ†ćƒ³ćƒ—ćƒ¬ćƒ¼ćƒˆę©Ÿčƒ½ć§
ē°”å˜ć«č³Ŗå•ć‚’ć¾ćØ悁悋

č³Ŗå•ć™ć‚‹

é–¢é€£ć—ćŸč³Ŗ問

åŒć˜ć‚æ悰恌恤恄恟č³Ŗå•ć‚’č¦‹ć‚‹

Xcode

XcodećÆć‚½ćƒ•ćƒˆć‚¦ć‚§ć‚¢é–‹ē™ŗć®ćŸć‚ć®ć€Apple恮ēµ±åˆé–‹ē™ŗē’°å¢ƒć§ć™ć€‚Mac OSXć«ä»˜éšć™ć‚‹ć‹ćŸć”ć§é…åøƒć•ć‚Œć¦ć„ć¾ć™ć€‚

Swift

SwiftćÆć€ć‚¢ćƒƒćƒ—ćƒ«ć®iOSćŠć‚ˆć³OS Xć®ćŸć‚ć®ćƒ—ćƒ­ć‚°ćƒ©ćƒŸćƒ³ć‚°č؀čŖžć§ć€Objective-C悄Objective-C++ćØå…±å­˜ć™ć‚‹ć“ćØćŒę„å›³ć•ć‚Œć¦ć„ć¾ć™