Posts

Post not yet marked as solved
32 Replies
Replied In New Forums?
I'm wondering how to use the search field. It appears you can search for tags with [TagName], if you know the tag name. Are there any other operators? For example, can you see posts after a certain date, or posts without any answers, or a marked answer?
Post not yet marked as solved
3 Replies
I created an OutlineView package here: https://github.com/EncodiaDotCo/OutlineView to address this. It's the first time I've created a public github repo for a Swift package, so hopefully it's usable. It's not pretty yet but it lazy loads children. Maybe we can cooperate and improve it. Feel free to create bug/feature requests.
Post not yet marked as solved
1 Replies
If it's the same problem I had, it's this: with multiplatform projects, those tests that Xcode creates for you are not unit tests, but "UI Tests". They do not link the same. You need to create more targets if you want to do unit testing. You'll see the Unit Test Bundle choice when you create a new target. I gave mine a similar name to the project template's UI Tests. So now I have "Tests macOS" and "Unit Tests macOS". The first is the UI Test bundle target created by Xcode. The second is my unit testing bundle. Linking works normally in there. .
Post marked as solved
1 Replies
My problem was caused by something dumb that I left out of my question, because I was trying to simplify it to post here. My UIScrollView was actually inside a SwiftUI view hierarchy, using UIViewRepresentable. Higher in that view hierarchy, there was a SwiftUI List, which also has scrolling. I had forgotten about that List because I was using it for it's layout appearance, grouping items into sections, but not for its scrolling. Once I got rid of that List, everything worked as expected.
Post not yet marked as solved
1 Replies
I think so, but I'm not sure exactly what you're trying to do. Here, I copied the code from the documentation for EditButton, and added some ability to select by tapping the text. (Probably you want to render the selection in a different way, not just green text, but I did that for simplicity.) struct ContentView: View {     @State private var fruits = [         "Apple",         "Banana",         "Papaya",         "Mango"     ]     @State private var selected = Set<String>()     var body: some View {         NavigationView{             List {                 ForEach(fruits, id: \.self) { fruit in                     Text(fruit)                         .foregroundColor( selected.contains(fruit) ? Color.green : nil )                         .onTapGesture { toggleSelected(fruit) }                 }                 .onDelete { self.deleteFruit(at :$0) }                 .onMove { self.moveFruit(from: $0, to: $1) }             }             .navigationTitle("Fruits")             .toolbar { EditButton() }         }     }     func toggleSelected(_ fruit: String) {         if selected.contains(fruit) { selected.remove(fruit) }         else { selected.insert(fruit) }     }     func deleteFruit(at: IndexSet) { fruits.remove(atOffsets: at) }     func moveFruit(from: IndexSet, to: Int) { fruits.move(fromOffsets: from, toOffset: to) } }
Post marked as solved
2 Replies
Due to some problem with git, I'd lost the Info.plist definitions of the "Document Types" and "Exported Type Identifiers". Once I added those back, this error disappeared.
Post marked as solved
4 Replies
Here's a simulator screenshot (iPhone SE). I've marked about where the border is, for the touch events. In my real app, with wider text, it's even further to the right, so that touching the first column of text actually spins the second picker.
Post not yet marked as solved
3 Replies
Apparently, I can't edit questions here like you can on StackOverflow. This is not caused by Xcode 12.5 exactly, it happened because I followed the suggestion to enable the "Hardened Runtime". So my question is really: can you unit test when the "Enable Hardened Runtime" build setting is "YES"?
Post not yet marked as solved
2 Replies
I just pasted your code into Xcode, ran it, and started clicking around. It seems a bit bogged down, because it can take over a second to change the VeryComplexView when I click on the different numbers in the left nav. But, the memory use is staying around 100-150MB. I'm running macOS 11.2.3, so maybe you could try upgrading to that?
Post not yet marked as solved
4 Replies
Sorry I don't have an answer, I think it's a great question. I played with your example code and I'm just as puzzled. I hope someone else can answer.
Post not yet marked as solved
7 Replies
Workingdogintokyo, it sounds like maybe this has changed in macOS 11.3 beta. I'm running 11.2.3. I pasted your example into a fresh project, and here is the output I get when I start the app, click in the 1st text field, then click in the 2nd text field. changed 1 ---- commit 1
Post not yet marked as solved
7 Replies
robnotyou, your example with the ZStack partly works for me. The return key triggers the behavior, but the problem is the Button is still visible, as a small blue rounded rectangle, behind the (apparently transparent) TextField. I'm satisfied with wrapping NSTextField for now. It has some properties and delegate callbacks to more precisely control this behavior.
Post not yet marked as solved
30 Replies
OOPer, I think you are being too nice, and have maybe too much patience. I would stop watching this thread, and if you like helping people here on the forums, spend time with others who respect your time, post code properly, and answer your questions.
Post not yet marked as solved
7 Replies
Sorry, I don't follow. There is no action: parameter for TextField, so what is would get triggered by the keyboard shortcut? I tried putting the modifier on it anyway, but the behavior is the same. TextField("Search", text: $searchQuery) { editing in .... } onCommit: { ... // still triggered by return OR focus loss }.keyboardShortcut(.defaultAction) I ended up using NSViewRepresentable and wrapping an NSTextField. So I have something working now, but I'd prefer to use pure SwiftUI if I can.
Post not yet marked as solved
1 Replies
What is the code doing? Is it drawing to a CGContext as you would in a UIView.draw method? If so, it sounds like you have to use UIViewRepresentable to create a UIView that you can then use in a SwiftUI View hierarchy.