Post

Replies

Boosts

Views

Activity

Scroll two lists synchronously
I have two lists side-by-side. I want to scroll any one of the lists, and the other one can scroll synchronously. Is there any way to achieve the effect? Any help will be appreciated. struct ScrollTwoListsSynchronously: View {     let dataSet = [1,2,3,4,5]     var body: some View {         HStack{             List{                 ForEach(dataSet,id:\.self){data in                     Text(String(data))                 }             }             .listStyle(PlainListStyle())             List{                 ForEach(dataSet,id:\.self){data in                     Text(String(data))                 }             }             .listStyle(PlainListStyle())         }     } }
0
0
541
May ’22
Invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific
I make a toggle to control a textfield in a form. When I run it, I get a piece of warning: invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution What could I do to fix it? What's the harm if it's not fixed( App crashes, or...?). Any help will be appreciated. struct ContentView: View {     @State private var toggle1 = true     @State private var str1 = "..."     var body: some View {         Form{             Section{                 Toggle(isOn: $toggle1, label: {                     Text("Toggle 1")})             }             Section{                     if toggle1{                         HStack{                             Text("Toggle 1")                             TextField("...", text: $str1)                         }                     }             }             .textFieldStyle(RoundedBorderTextFieldStyle())         }     } }
0
1
1.2k
Jan ’22
debug problem in Xcode13
struct ContentView: View {     @State private var num = 0          var body: some View {         VStack{         Text(String(num))             .padding()         Button(action: {             num += 1         }, label: {Text("click+1")})         }     } } Question 1: If I run the code above on simulator, I could get the value of "num" on the console by using"po _num". However, if I run the code in previews(by "Debug-Attach to process"), I only get the error"error: :3:1: error: cannot find '_num' in scope" on the console by using"po _num" Xcode 13.2.1 Question 2: I could use "po num"/"po _num" to get the value of "num" with Xcode 12. BUT, only "po _num" works in Xcode13. "po num" will raise the error:" error: Couldn't lookup symbols: Preview2.ContentView.num.getter : Swift.Int" Any help will be appreciated.
0
0
1.3k
Dec ’21
"onTapGesture" interferes with segmented picker
struct ProblemSegmentTest: View {     @State private var select = 0     var body: some View {         VStack {             Picker("Test", selection: $select) {                 Text("A").tag(0)                 Text("B").tag(1)                 Text("C").tag(2)             }             .pickerStyle(SegmentedPickerStyle())         }         .onTapGesture {             print("test")         }     } } I want to do sth when the picker is taped. However, when I apply ".onTapGesture" to the vstack, the picker's options can't be selected any more. Any help will be appreciated.
5
1
2.0k
Oct ’21
What's the difference between InlinePickerStyle and WheelPickerStyle
struct PickerStyleView: View {     @State private var num  =  0     var body: some View {         Form{             Text("Number")             Picker(String(num), selection: $num, content: {                                  Text("5").tag(5)                 Text("10").tag(10)                 Text("15").tag(15)                 Text("20").tag(20)             })             .pickerStyle(InlinePickerStyle())         }     } } Using InlinePickerStyle() and WheelPickerStyle() seems to be no difference. What does "InlinePickerStyle()" refer to? And which case is "InlinePickerStyle()" suitable for in practice? Any help will be appreciated.
1
0
797
Sep ’21
Scroll two lists synchronously
I have two lists side-by-side. I want to scroll any one of the lists, and the other one can scroll synchronously. Is there any way to achieve the effect? Any help will be appreciated. struct ScrollTwoListsSynchronously: View {     let dataSet = [1,2,3,4,5]     var body: some View {         HStack{             List{                 ForEach(dataSet,id:\.self){data in                     Text(String(data))                 }             }             .listStyle(PlainListStyle())             List{                 ForEach(dataSet,id:\.self){data in                     Text(String(data))                 }             }             .listStyle(PlainListStyle())         }     } }
Replies
0
Boosts
0
Views
541
Activity
May ’22
keyboard can't be popped up in live preview mode
In the simulator, everything is ok. However, in live preview mode of canvas, no keyboard pops up when I tap in the textfield. Did I miss anything? Or need more codes in preview?Thanks in advance.
Replies
6
Boosts
0
Views
16k
Activity
Apr ’22
Invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific
I make a toggle to control a textfield in a form. When I run it, I get a piece of warning: invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution What could I do to fix it? What's the harm if it's not fixed( App crashes, or...?). Any help will be appreciated. struct ContentView: View {     @State private var toggle1 = true     @State private var str1 = "..."     var body: some View {         Form{             Section{                 Toggle(isOn: $toggle1, label: {                     Text("Toggle 1")})             }             Section{                     if toggle1{                         HStack{                             Text("Toggle 1")                             TextField("...", text: $str1)                         }                     }             }             .textFieldStyle(RoundedBorderTextFieldStyle())         }     } }
Replies
0
Boosts
1
Views
1.2k
Activity
Jan ’22
debug problem in Xcode13
struct ContentView: View {     @State private var num = 0          var body: some View {         VStack{         Text(String(num))             .padding()         Button(action: {             num += 1         }, label: {Text("click+1")})         }     } } Question 1: If I run the code above on simulator, I could get the value of "num" on the console by using"po _num". However, if I run the code in previews(by "Debug-Attach to process"), I only get the error"error: :3:1: error: cannot find '_num' in scope" on the console by using"po _num" Xcode 13.2.1 Question 2: I could use "po num"/"po _num" to get the value of "num" with Xcode 12. BUT, only "po _num" works in Xcode13. "po num" will raise the error:" error: Couldn't lookup symbols: Preview2.ContentView.num.getter : Swift.Int" Any help will be appreciated.
Replies
0
Boosts
0
Views
1.3k
Activity
Dec ’21
"onTapGesture" interferes with segmented picker
struct ProblemSegmentTest: View {     @State private var select = 0     var body: some View {         VStack {             Picker("Test", selection: $select) {                 Text("A").tag(0)                 Text("B").tag(1)                 Text("C").tag(2)             }             .pickerStyle(SegmentedPickerStyle())         }         .onTapGesture {             print("test")         }     } } I want to do sth when the picker is taped. However, when I apply ".onTapGesture" to the vstack, the picker's options can't be selected any more. Any help will be appreciated.
Replies
5
Boosts
1
Views
2.0k
Activity
Oct ’21
What's the difference between InlinePickerStyle and WheelPickerStyle
struct PickerStyleView: View {     @State private var num  =  0     var body: some View {         Form{             Text("Number")             Picker(String(num), selection: $num, content: {                                  Text("5").tag(5)                 Text("10").tag(10)                 Text("15").tag(15)                 Text("20").tag(20)             })             .pickerStyle(InlinePickerStyle())         }     } } Using InlinePickerStyle() and WheelPickerStyle() seems to be no difference. What does "InlinePickerStyle()" refer to? And which case is "InlinePickerStyle()" suitable for in practice? Any help will be appreciated.
Replies
1
Boosts
0
Views
797
Activity
Sep ’21